Skip to content

Commit

Permalink
Update to use idlize
Browse files Browse the repository at this point in the history
  • Loading branch information
philipwalton committed Sep 20, 2018
1 parent 863acbb commit 703ee09
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 1,311 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ gulp.task('js:test', ((compiler) => {
// Note: comment this rule out when testing for easier debugging.
rules: [
{
test: /\.js$/,
test: /\.m?js$/,
use: {
loader: 'babel-loader',
options: {
Expand Down
205 changes: 0 additions & 205 deletions lib/idle-queue.js

This file was deleted.

70 changes: 0 additions & 70 deletions lib/idle-value.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/plugins/event-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class EventTracker {
* @param {Element} element The delegated DOM element target.
*/
handleEvents(event, element) {
this.queue.add(({time}) => {
this.queue.pushTask(({time}) => {
const prefix = this.opts.attributePrefix;
const events = element.getAttribute(prefix + 'on').split(/\s*,\s*/);

Expand Down
10 changes: 5 additions & 5 deletions lib/plugins/impression-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class ImpressionTracker {
* @param {Array<!ImpressionTrackerElementsItem|string>} elements
*/
observeElements(elements) {
this.queue.add(() => {
this.queue.pushTask(() => {
const data = this.deriveDataFromElements(elements);

// Merge the new data with the data already on the plugin instance.
Expand Down Expand Up @@ -133,7 +133,7 @@ class ImpressionTracker {
unobserveElements(elements) {
// Since observing elements is queued, unobserving must be queued also or
// we risk this running before the observing.
this.queue.add(() => {
this.queue.pushTask(() => {
const itemsToKeep = [];
const itemsToRemove = [];

Expand Down Expand Up @@ -189,7 +189,7 @@ class ImpressionTracker {
unobserveAllElements() {
// Since observing elements is queued, unobserving must be queued also or
// we risk this running before the observing.
this.queue.add(() => {
this.queue.pushTask(() => {
Object.keys(this.thresholdMap).forEach((key) => {
this.thresholdMap[key].disconnect();
});
Expand Down Expand Up @@ -271,7 +271,7 @@ class ImpressionTracker {
* @param {Array} records A list of `IntersectionObserverEntry` records.
*/
handleIntersectionChanges(records) {
this.queue.add(({time}) => {
this.queue.pushTask(({time}) => {
const itemsToRemove = [];
for (let i = 0, record; record = records[i]; i++) {
for (let j = 0, item; item = this.items[j]; j++) {
Expand All @@ -297,7 +297,7 @@ class ImpressionTracker {
* @param {{id: (string), impressionTime: (number)}} param1
*/
handleImpression({id, impressionTime}) {
this.queue.add(() => {
this.queue.pushTask(() => {
const element = document.getElementById(id);

/** @type {FieldsObj} */
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/max-scroll-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class MaxScrollTracker {
const scrollPos = window.pageYOffset; // scrollY isn't supported in IE.
const windowHeight = window.innerHeight;

this.queue.add(({time}) => {
this.queue.pushTask(({time}) => {
// Ensure scrollPercentage is an integer between 0 and 100.
const scrollPercentage = Math.min(100, Math.max(0,
Math.round(100 * (scrollPos / (pageHeight - windowHeight)))));
Expand Down Expand Up @@ -175,7 +175,7 @@ class MaxScrollTracker {
* @param {number} scrollTimestamp
*/
sendMaxScrollEvent(increaseAmount, scrollPercentage, scrollTimestamp) {
this.queue.add(() => {
this.queue.pushTask(() => {
/** @type {FieldsObj} */
const defaultFields = {
transport: 'beacon',
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/media-query-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class MediaQueryTracker {
* }} param1
*/
sendChangeEvent({definition, oldValue, newValue}) {
this.queue.add(({time}) => {
this.queue.pushTask(({time}) => {
/** @type {FieldsObj} */
const defaultFields = {
transport: 'beacon',
Expand Down
Loading

0 comments on commit 703ee09

Please sign in to comment.