Can any one advise when I render a page I can check to see what blocks have been used in out block grids.
I am relying on some JavaScript to do some effects on a block they are firing on page load.
let ranStatCount = false;
var $this = $('#@id');
var elementTarget = document.getElementById('@id');
var position = elementTarget.getBoundingClientRect();
// If the elements are in the top of the page view,
// increment the stat count straight away
if (position.top >= 0 && position.bottom <= window.innerHeight) {
IncrementStatCount($this);
}
We have added addEventListener that added to each of the blocks, that executes the above code.
That should execure when get to a specific section of the page, but it executing on load.
I have used the same position check in other code that runs on .ready and that correctly works when the page is set to a specific position.
But when I use a block it not.
Is there a way to detect if specific blocks have been used on the page, and then I can add the correct javascript on the .ready event.
Umbraco Block Grid
Hi,
Can any one advise when I render a page I can check to see what blocks have been used in out block grids.
I am relying on some JavaScript to do some effects on a block they are firing on page load.
let ranStatCount = false; var $this = $('#@id');
var elementTarget = document.getElementById('@id'); var position = elementTarget.getBoundingClientRect();
// If the elements are in the top of the page view, // increment the stat count straight away if (position.top >= 0 && position.bottom <= window.innerHeight) { IncrementStatCount($this); }
We have added addEventListener that added to each of the blocks, that executes the above code.
That should execure when get to a specific section of the page, but it executing on load.
I have used the same position check in other code that runs on .ready and that correctly works when the page is set to a specific position.
But when I use a block it not.
Is there a way to detect if specific blocks have been used on the page, and then I can add the correct javascript on the .ready event.
is working on a reply...