You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
/* global woodmart_settings */
|
|
(function($) {
|
|
$.each([
|
|
'frontend/element_ready/wd_counter.default'
|
|
], function(index, value) {
|
|
woodmartThemeModule.wdElementorAddAction(value, function() {
|
|
woodmartThemeModule.visibleElements();
|
|
});
|
|
});
|
|
|
|
woodmartThemeModule.counterShortcode = function(counter) {
|
|
if (counter.attr('data-state') === 'done' || parseInt(counter.text()) !== counter.data('final')) {
|
|
return;
|
|
}
|
|
|
|
counter.prop('Counter', 0).animate({
|
|
Counter: counter.text()
|
|
}, {
|
|
duration: parseInt(woodmart_settings.animated_counter_speed),
|
|
easing : 'swing',
|
|
step : function(now) {
|
|
if (now >= counter.data('final')) {
|
|
counter.attr('data-state', 'done');
|
|
}
|
|
|
|
counter.text(Math.ceil(now));
|
|
}
|
|
});
|
|
};
|
|
|
|
woodmartThemeModule.visibleElements = function() {
|
|
$('.woodmart-counter .counter-value').each(function() {
|
|
var $this = $(this);
|
|
|
|
$this.waypoint(function() {
|
|
woodmartThemeModule.counterShortcode($this);
|
|
}, {offset: '100%'});
|
|
});
|
|
};
|
|
|
|
$(document).ready(function() {
|
|
woodmartThemeModule.visibleElements();
|
|
});
|
|
})(jQuery);
|
|
|