Last active
August 21, 2018 04:17
-
-
Save thanh4890/7b31f506c11f14db73d02117831f3469 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//script check scroll to block then load mkt form | |
var contactUsFormBlock = document.getElementsByClassName('section-contact-us-form')[0]; | |
var Mkt1092LoadCount = 0; | |
window.addEventListener('scroll', function () { | |
if (Mkt1092LoadCount === 0) { | |
var hT = contactUsFormBlock.offsetTop, | |
hH = contactUsFormBlock.offsetHeight, | |
wH = window.innerHeight, | |
wS = this.pageYOffset; | |
if (wS > (hT + hH - wH)) { | |
MktoForms2.loadForm("//app-sn02.marketo.com", "514-XGZ-156", 1092); | |
Mkt1092LoadCount = Mkt1092LoadCount + 1; | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var blockClassScrollToArray = ["call-to-contact-form", "block-bottom-navigation"]; | |
var blockScrollToArray = []; | |
blockClassScrollToArray.forEach(function (className) { | |
var element = document.getElementsByClassName(className)[0] | |
var item = { | |
class: element, | |
value: element.offsetTop | |
} | |
blockScrollToArray.push(item) | |
}) | |
//sort array | |
blockScrollToArray.sort(function (a, b) { | |
return a.value - b.value; | |
}); | |
if (blockScrollToArray.length > 0) { | |
var blockFirst = blockScrollToArray[0].class; | |
if (blockFirst) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment