UNPKG

vue-auto-track

Version:

auto tracking for vue

17 lines (16 loc) 430 B
export default class Exposure { constructor(context, options) { this.observer = this.init(context, options) } init(context = null, options = {}) { return uni.createIntersectionObserver(context, { thresholds: [0, 0.5, 1], ...options }) } startObserver(selector, fn) { this.observer.relativeTo().observe(selector, (res) => { fn && fn(res) }) } disconnect() { this.observer.disconnect() } }