SwAdFloating

Ad Placement Four Essentials

  • Use case: fixed floating slots on the page left / right, auto-hidden on narrow screens (slotKey e.g. floating_right)
  • Industry form: Floating / Anchor ads (a framework-specific extension; AdSDK has no matching format, ad_type uses the extension value floating)
  • Visual form: vertical stack of images (items renders all entries; businesses typically configure up to ~6, each about 60×60), hidden when the window width ≤ hiddenWidth
  • Tracking events: adImpression (reported once for the whole group when visible) / adClick (per item); silent no-op when the tracker gate is off

Picking the wrong scenario = wrong ad_type / timing in tracking. See Ad Component Selection.

SwAdFloating is the side floating ad slot component — a "popup / floating-type" self-rendering component of the ad foundation. It sticks to the left / right viewport edge, renders all items as a vertical stack (as many as the data provides), and shows only when the window width ≥ hiddenWidth (auto-hidden on narrow screens, never crowding content). Impression / click tracking is built in.

Side floating ad

加载中...

Group-level inline badge (bottom)

加载中...

CSS variables (width/gap)

加载中...

hiddenWidth narrow-screen hide

加载中...

Events (group impression once)

加载中...

Props

NameTypeRequiredDefaultDescription
itemsSwAdItem[]✓—Ad creative array
slotKeystring✓—Ad slot key → ad_slot_key
slotNamestringundefinedAd slot name → ad_slot_name
pageKeystringundefinedPage key → page_key
pageNamestringundefinedPage name → page_name
position'left' | 'right''right'Which edge to stick to
hiddenWidthnumber1500Hide when window width is below this value (px)
ratiostring'1/1'Creative aspect ratio
radiusnumber | string8Corner radius (number = px, string passed to SwImage as-is, e.g. '1.125rem')
showAdLabelbooleanundefined"Ad" compliance badge (inline variant, one per group, centered at the bottom); when not set it follows the global swiftConfig.ad.showLabel (default true), an explicit value always wins

CSS Variables

VariableDefaultDescription
--sw-ad-floating-width3.75rem (60px)Per-image width (height follows ratio)
--sw-ad-floating-gap0.5remVertical gap between images

Events

NamePayloadDescription
load—Rendered
empty—items empty
impressionitems: SwAdItem[]Impression (auto tracking)
clickitem: SwAdItemClick (auto tracking)
error—Render / load error
<!-- items render as a vertical stack (count controlled by data, typically ≤6), each 60×60 by default -->
<SwAdFloating :items="sideAds" slot-key="global_side" position="right" :hidden-width="1280" show-ad-label />

<!-- Larger per-image size -->
<SwAdFloating :items="sideAds" slot-key="global_side" style="--sw-ad-floating-width: 5rem" />

Caveats

  • Auto-hidden on narrow screens — not rendered when the window is below hiddenWidth, avoiding occluding mobile / narrow-viewport content.
  • Usually mounted once in the global layout, fixed in place; tracking is built in and gated.