0
我正在使用一些JavaScript和jQuery(使用easing插件)来创建虚拟漫游;真的只是一个可以平移左右的长影像。我发现这是完美的原因:http://jsfiddle.net/MvRdD/1/。有没有办法给动画添加缓动?将图像添加到图像pan
我正在使用一些JavaScript和jQuery(使用easing插件)来创建虚拟漫游;真的只是一个可以平移左右的长影像。我发现这是完美的原因:http://jsfiddle.net/MvRdD/1/。有没有办法给动画添加缓动?将图像添加到图像pan
http://jsfiddle.net/ARTsinn/MvRdD/890/
$(document).ready(function() {
$.getScript("https://raw.github.com/danro/easing-js/master/easing.min.js");
var animateTime = 10,
offsetStep = 5,
scrollWrapper = $('#wrap');
//event handling for buttons "left", "right"
var aktiv;
$('.bttL, .bttR').mousedown(function(e) {
if (e.target.className === 'bttR') {
aktiv = window.setInterval(function() {
scrollWrapper.animate({
scrollLeft: '+=' + 20
}, {
duration: 600,
queue: false,
easing: 'easeOutCirc'
});
}, 10);
} else if (e.target.className === 'bttL') {
aktiv = window.setInterval(function() {
scrollWrapper.animate({
scrollLeft: '-=' + 20
}, {
duration: 1200,
queue: false,
easing: 'easeOutCirc'
});
}, 10);
}
}).mouseup(function() {
window.clearInterval(aktiv);
});
scrollWrapper.mousedown(function(event) {
$(this).data('down', true).data('x', event.clientX).data('scrollLeft', this.scrollLeft);
return false;
}).mouseup(function(event) {
$(this).data('down', false);
}).mousemove(function(event) {
if ($(this).data('down')) {
$(this).stop(false, true).animate({
scrollLeft: $(this).data('scrollLeft') + ($(this).data('x') - event.clientX) * 2
}, {
duration: 600,
queue: false,
easing: 'easeOutCirc'
});
}
}).mousewheel(function(event, delta) {
$(this).stop(false, true).animate({
scrollLeft: '-=' + delta * 60
}, {
duration: 400,
queue: false,
easing: 'easeOutCirc'
});
event.preventDefault();
}).css({
'overflow': 'hidden',
'cursor': '-moz-grab'
});
});
没办法啊,这是真棒!它在拖动和鼠标滚轮上确实轻松,但不会按下按钮? – legoman
这就是你现在学习JavaScript的一部分:)如果你在超过30分钟内失败了,只需重新写一遍,我也会为你完成这部分: - * – yckart
明天就要到了,但是忍耐着我! – legoman