ScrollY Position - Übergibt die Scroll Position an das Creative (y)
//Parses scrollValues to html5 via external interface updated version v4
(function () {
o.scrollY = {
getScrollY: function () {
var scrOfY = o.w.pageYOffset || o.w.document.body.scrollTop;
return scrOfY;
},
submitScroll: function () {
var p = o.scrollY,
scrollObject = {
yPos: p.getScrollY(),
yMax: p.getDocHeight()
};
try {
o.dispatchToCreative('onScroll', scrollObject);
} catch (e) {}
},
getDocHeight: function () {
var p = o.scrollY;
p.yMax = Math.max(
Math.max(o.w.document.body.scrollHeight, o.w.document.documentElement.scrollHeight),
Math.max(o.w.document.body.offsetHeight, o.w.document.documentElement.offsetHeight),
Math.max(o.w.document.body.clientHeight, o.w.document.documentElement.clientHeight)
);
return p.yMax;
},
init: function () {
o.addEventListener("adonpage", function () {
var p = o.scrollY;
if (typeof o.w.addEventListener !== "undefined") {
o.w.addEventListener("scroll", p.submitScroll, true);
} else {
o.w.attachEvent("onscroll", p.submitScroll);
}
});
o.addEventListener("adready", function () {
var p = o.scrollY;
p.submitScroll();
});
o.addEventListener("start", function () {
var p = o.scrollY;
o.flashVar('yMax', p.getDocHeight());
});
}()
};
})();
// window.parent - Anpassung für Media Impact und EMS
// Parses scrollValues to html5 via external interface updated version v4 - amended for MEDIA IMPACT
(function () {
if (!o.macSaf()) {
o.scrollY = {
getScrollY: function () {
var scrOfY = window.parent.pageYOffset || window.parent.document.body.scrollTop;
return scrOfY;
},
submitScroll: function () {
var p = o.scrollY,
scrollObject = {
yPos: p.getScrollY(),
yMax: p.getDocHeight()
};
try {
o.dispatchToCreative('onScroll', scrollObject);
} catch (e) {}
},
getDocHeight: function () {
var p = o.scrollY;
p.yMax = Math.max(
Math.max(window.parent.document.body.scrollHeight, window.parent.document.documentElement.scrollHeight),
Math.max(window.parent.document.body.offsetHeight, window.parent.document.documentElement.offsetHeight),
Math.max(window.parent.document.body.clientHeight, window.parent.document.documentElement.clientHeight)
);
return p.yMax;
},
init: function () {
o.addEventListener("adonpage", function () {
var p = o.scrollY;
if (typeof window.parent.addEventListener !== "undefined") {
window.parent.addEventListener("scroll", p.submitScroll, true);
} else {
window.parent.attachEvent("onscroll", p.submitScroll);
}
});
o.addEventListener("adready", function () {
var p = o.scrollY;
p.submitScroll();
});
o.addEventListener("start", function () {
var p = o.scrollY;
o.flashVar('yMax', p.getDocHeight());
});
}()
};
}
})();
// Usage in Creative
myFT.on("onScroll", function(payload) {
console.log(payload.yPos); //scroll position
console.log(payload.yMax); // maximal scroll height
});