मैंने एक लंबन स्क्रॉल बनाया है, जो फ़ायरफ़ॉक्स में ठीक काम कर रहा है, हालांकि क्रोम ब्राउज़र में स्क्रॉल करते समय बॉडी टेक्स्ट पर थोड़ी सी कूद है। click here scroll to the about section। मुझे यकीन नहीं है कि यह एक सीएसएस या जेएस मुद्दा है .. नीचे एक स्निपेट है जिसे मैंने अपने लंबन समारोह में शामिल किया हैलंबन स्क्रॉलिंग समस्या - वेबकिट ब्राउज़र में स्क्रॉल करते समय div तत्व jerking
क्या कोई जानता है कि मैं इस समस्या को कैसे ठीक करता हूं?
$(document).ready(function(){
// Cache the Window object
$window = $(window);
// Cache the Y offset and the speed of each sprite
$('[data-type]').each(function() {
$(this).data('offsetY', parseInt($(this).attr('data-offsetY')));
$(this).data('Xposition', $(this).attr('data-Xposition'));
$(this).data('speed', $(this).attr('data-speed'));
});
// For each element that has a data-type attribute
$('[data-type="background"]').each(function(){
// Store some variables based on where we are
var $self = $(this),
offsetCoords = $self.offset(),
topOffset = offsetCoords.top;
// When the window is scrolled...
$(window).scroll(function() {
// If this section is in view
if (($window.scrollTop() + $window.height()) > (topOffset) &&
((topOffset + $self.height()) > $window.scrollTop())) {
// Scroll the background at var speed
// the yPos is a negative value because we're scrolling it UP!
var yPos = -($window.scrollTop()/$self.data('speed'));
// If this element has a Y offset then add it on
if ($self.data('offsetY')) {
yPos += $self.data('offsetY');
}
// Put together our final background position
var coords = '50% '+ yPos + 'px';
// Move the background
$self.css({ backgroundPosition: coords });
$('[data-type="scroll-text"]', $self).each(function() {
var $text= $(this);
var pos = ($window.scrollTop()/10) * $text.data('speed');
var curP = $text.css('margin-top');
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if(is_chrome) {
$text.animate({
paddingTop: pos,
}, 200, 'linear', function() {
// Animation complete.
});
} else {
$text.css('padding-top', pos);
}
});
}; // in view
}); // window scroll
}); // each data-type
}); // document ready
आपका कोड सरल अनुकूलन से लाभ होगा: 1) 'कॉल $ (विंडो) .scrollTop()' सिर्फ एक बार और मूल्य को कैश, 2) '[डेटा-पाठ]' बाहर तत्वों के लिए डोम क्वेरी घटना श्रोता का। –
@IanKuca क्या आप इस अबाउट पर विस्तार कर सकते हैं, या यहां तक कि जेएसबी पर जेएस संपादित कर सकते हैं। मैं जावास्क्रिप्ट – NewBoy
पर सबसे महान नहीं हूं http://pastebin.com/JCaA7T6A –