@adapt-retail/adapt-event 中文文档教程

发布于 7年前 浏览 6 项目主页 更新于 3年前

@adapt-retail/adapt-data

⚠️ 此软件包尚未作为稳定版本发布,可能会发生变化。

Adapt Retail 中轻松调度事件。

Install

npm install @adapt-retail/adapt-event

Usage

事件类将帮助您在 Adapt Retail 中调度事件。 您可以使用它来跟踪您喜欢的任何事件,但我们为您提供了一些预配置的事件。

Import to project

安装后,只需使用普通节点语法导入包即可。

// EcmaScript6 and up
import AdaptEvent from '@adapt-retail/adapt-event';

Dispatching events

/*
 * @param event
 * @param description (optional)
 * @param position (optional)
 * 
 * @return void
 */
AdaptEvent.dispatch( 'Event name', 'Description' );

如果您调度 MouseEvent,请将事件添加为第三个参数 跟踪点击发生的位置。

var logo = document.querySelector( '.logo' );

logo.addEventListener( 'click', function( event ) {
    AdaptEvent.dispatch( 'click', 'on-logo', event );
} );

Plugins

可以使用插件扩展 AdaptEvent 的功能。 这可能是 f.eks。 扩展事件以匹配其他显示网络,例如 Google Double Click 和 AdForm。

阅读如何构建您自己的文档

AdaptEvent.addPlugin( new Plugin );

Default plugins

我们还包括一些默认插件,让您的生活更轻松。

阅读更多文档

// Import and add plugin
import {
    AdaptEvent,
    AdaptClickEvent,
    AdaptGoogleAnalythics
} from '@adapt-retail/adapt-event';

AdaptEvent.addPlugin( new AdaptClickEvent );
AdaptEvent.addPlugin( new AdaptGoogleAnalythics );


// Track a click 
document.querySelector( '.logo' ).adaptClick( function( event ) {
    ...
}, 'a-click', 'logo' );

// Track click and navigate to url
document.querySelector( '.logo' )
    .adaptClickAndNavigate( 'https://adaptretail.com', 'navigate', 'from-logo' );

Development

# Install dependencies
npm install

# Run test suit
npm run test

# Run test suite on file change
npm run tdd

@adapt-retail/adapt-data

⚠️ This package has not been released as a stable release, and changes may occur.

Easy dispatching of events in Adapt Retail.

Install

npm install @adapt-retail/adapt-event

Usage

The event class will help you dispatch events in Adapt Retail. You can use it to track whatever event you like, but we got some preconfigured events for you.

Import to project

When installed, simply import the package with normal node syntax.

// EcmaScript6 and up
import AdaptEvent from '@adapt-retail/adapt-event';

Dispatching events

/*
 * @param event
 * @param description (optional)
 * @param position (optional)
 * 
 * @return void
 */
AdaptEvent.dispatch( 'Event name', 'Description' );

If you dispatching an MouseEvent, add the event as the third parameter to track where the click occur.

var logo = document.querySelector( '.logo' );

logo.addEventListener( 'click', function( event ) {
    AdaptEvent.dispatch( 'click', 'on-logo', event );
} );

Plugins

It is possible to extend the functionality of the AdaptEvent using plugins. This could be f.eks. extending the event to match other display networks, such as Google Double Click and AdForm.

Read how to build your own in the documentation

AdaptEvent.addPlugin( new Plugin );

Default plugins

We are also including some default plugins to make your life easier.

Read more in the documentation

// Import and add plugin
import {
    AdaptEvent,
    AdaptClickEvent,
    AdaptGoogleAnalythics
} from '@adapt-retail/adapt-event';

AdaptEvent.addPlugin( new AdaptClickEvent );
AdaptEvent.addPlugin( new AdaptGoogleAnalythics );


// Track a click 
document.querySelector( '.logo' ).adaptClick( function( event ) {
    ...
}, 'a-click', 'logo' );

// Track click and navigate to url
document.querySelector( '.logo' )
    .adaptClickAndNavigate( 'https://adaptretail.com', 'navigate', 'from-logo' );

Development

# Install dependencies
npm install

# Run test suit
npm run test

# Run test suite on file change
npm run tdd
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文