Answer the question
In order to leave comments, you need to log in
Why doesn't the script fire in IE11 on load, but only on window resize?
Good afternoon!
There is a site with horizontal scrolling. The site is navigated using the jquery mousewheel (turn the wheel down - the site scrolls horizontally).
For everything to work correctly, the main DIV container must be given a fixed width, which consists of the sum of all child DIVs (they can be either fixed or equal to the width of the visitor's screen).
All this is done using a script:
// Считаем ширину экрана
var smWidth = (function () {
$('.full').css('width', $(window).width()); // Задаем элементам с данным классом ширину равную экрану
});
// Горизонтальная прокрутка скроллом
function windowSize(){
var ScWidth = $(document).width(); // Узнаем ширину окна
if (ScWidth > '991'){
// Если ширна больше значения, выполняем горизонтальную прокрутку
$('html, body, *').mousewheel(function(e, delta) {
// Интенсивность скролла 80
var isMac = /mac/i.test(navigator.platform);
if (isMac) {
this.scrollLeft -= (delta * 2);
} else {
this.scrollLeft -= (delta * 80);
}
e.preventDefault();
});
$(function() {
// Назначаем ширин блоку равную сумме блоков с классом calcme
overallwidth = 0;
$('.calcme').each(function() {
overallwidth = overallwidth + $(this).width() + parseInt($(this).css('padding-left')) + parseInt($(this).css('padding-right')) + parseInt($(this).css('margin-left')) + parseInt($(this).css('margin-right'));
});
$('.content').css('width', overallwidth);
});
}
// Если ширина меньше, то ничего не делаем
};
// Выполняем при загрузке
$(document).ready(function() {
smWidth();
windowSize();
});
// Выполняем при измении экрана
$(window).resize(function() {
smWidth();
windowSize();
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question