ページプッシュ
スクリプト: https://koin-ad.click/page-push/v1/main.js
要素: <x-push>
グローバルオブジェクト: push
共通のメソッドは 広告タグ API にあります。ページプッシュは show(options) と 4 つの属性を追加します。
インストール
カードを出したいときに show() を呼び出してください。要素を返します。スクリプトが要素名を登録していなければ、null を返します。
html
<script>
function onKoinPush() {
push.show({
displayTime: 8000,
position: 'bottom-left',
});
}
</script>
<script
async
src="https://koin-ad.click/page-push/v1/main.js?id=UNIT_ID"
onload="onKoinPush()"
></script><script> タグは 1 つだけにしてください。このファイルを 2 回読み込まないでください。
要素を自分で置くこともできます。
html
<x-push display-time="8000" position="bottom-left"></x-push>show(options)
どのフィールドも省略できます。
| フィールド | 属性 | 既定 | 意味 |
|---|---|---|---|
displayTime | display-time | 5000 | カードが自ら閉じるまで表示する時間。ミリ秒 |
animationTime | animation-time | 300 | 入場と退場のアニメーション。ミリ秒 |
defaultClose | default-close | true | displayTime が終わったら閉じる |
position | position | bottom-right | 画面の隅 |
displayTime と animationTime は、ゼロまたは正の数でなければなりません。それ以外の値は既定値を使います。
default-close は true、false、1、0 を受け付けます。
position は top-left、top-right、bottom-left、bottom-right のいずれかです。それ以外の値は bottom-right になります。
js
const card = push.show({
displayTime: 0,
defaultClose: false,
animationTime: 200,
position: 'top-right',
});displayTime: 0 または defaultClose: false にすると、訪問者が閉じるか、あなたが push.close() を呼ぶまで、カードは表示されたままです。
訪問者が閉じるときは、退場アニメーションを再生してから要素を外します。push.close() はすぐに外します。
theme() の名前
| 名前 | 選択対象 |
|---|---|
push | <x-push> 要素 |
card | カード |
cover | 画像 |
body | テキストの領域 |
title | タイトル |
subtitle | 説明 |
prompt | 行動を促す行 |
micro-label | 小さいラベル |
badge-icon | バッジ |
svg-icon | アイコン |
カードは position: fixed で、幅は 380px、選んだ隅から 16px 内側です。push はその外側の箱のセレクタです。