Authored by 梁志锋

提交gulp ge文件

@@ -5496,44 +5496,99 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) { @@ -5496,44 +5496,99 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) {
5496 isSelected = isThisGoodSelected; 5496 isSelected = isThisGoodSelected;
5497 } 5497 }
5498 5498
5499 -function preventDefault(event) {  
5500 - var e = event || window.event; 5499 +function preventDefault(e) {
  5500 + e = e || window.event;
  5501 + e.preventDefault && e.preventDefault();
  5502 + e.returnValue = false;
  5503 +}
5501 5504
5502 - var $target = $(e.target); 5505 +function stopPropagation(e) {
  5506 + e = e || window.event;
  5507 + e.stopPropagation && e.stopPropagation();
  5508 + e.cancelBubble = false;
  5509 +}
5503 5510
5504 - if (($target.hasClass('.chose-items') || $target.closest('chose-items')) &&  
5505 - ($('.color-list').find('ul').not('.hide').find('li').length > 4 ||  
5506 - $('.size-list').find('ul').not('.hide').find('li').length > 4)) {  
5507 - e.stopPropagation();  
5508 - return false;  
5509 - } 5511 +function innerScroll(e) {
  5512 + var delta = e.wheelDelta || e.originalEvent.wheelDelta || e.detail || 0,
  5513 + box = $(this).get(0);
5510 5514
5511 - if (e.preventDefault) {  
5512 - e.preventDefault(); 5515 + // 阻止冒泡到document
  5516 + // document上已经preventDefault
  5517 + stopPropagation(e);
  5518 +
  5519 +
  5520 + if ($(box).height() + box.scrollTop >= box.scrollHeight) {
  5521 + if (delta < 0) {
  5522 + preventDefault(e);
  5523 + return false;
  5524 + }
  5525 + }
  5526 + if (box.scrollTop === 0) {
  5527 + if (delta > 0) {
  5528 + preventDefault(e);
  5529 + return false;
  5530 + }
5513 } 5531 }
5514 - e.returnValue = false;  
5515 } 5532 }
5516 5533
5517 -function disableScroll(e) { 5534 +function disableScroll() {
  5535 + var startX, startY;
5518 5536
5519 - // older FF  
5520 - if (window.addEventListener) {  
5521 - window.addEventListener('DOMMouseScroll', preventDefault, false);  
5522 - } 5537 + var $choseArea = $('.chose-panel .main .chose-items');
  5538 +
  5539 + // 内部可滚
  5540 + $choseArea.on('mousewheel', innerScroll);
  5541 +
  5542 + // 移动端touch重写
  5543 + $choseArea.on('touchstart', function(e) {
  5544 + startX = e.originalEvent.changedTouches[0].pageX;
  5545 + startY = e.originalEvent.changedTouches[0].pageY;
  5546 + });
  5547 +
  5548 + // 仿innerScroll方法
  5549 + $choseArea.on('touchmove', function(e) {
  5550 + var deltaX = e.originalEvent.changedTouches[0].pageX - startX,
  5551 + deltaY = e.originalEvent.changedTouches[0].pageY - startY;
  5552 +
  5553 + var box = $(this).get(0);
  5554 +
  5555 + e.stopPropagation();
  5556 +
  5557 +
  5558 + // 只能纵向滚
  5559 + if (Math.abs(deltaY) < Math.abs(deltaX)) {
  5560 + e.preventDefault();
  5561 + return false;
  5562 + }
  5563 +
  5564 +
  5565 + if ($(box).height() + box.scrollTop >= box.scrollHeight) {
  5566 + if (deltaY < 0) {
  5567 + e.preventDefault();
  5568 + return false;
  5569 + }
  5570 + }
  5571 + if (box.scrollTop === 0) {
  5572 + if (deltaY > 0) {
  5573 + e.preventDefault();
  5574 + return false;
  5575 + }
  5576 + }
  5577 + });
5523 5578
5524 - window.onwheel = preventDefault; // modern standard  
5525 - window.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE  
5526 - window.ontouchmove = preventDefault; // mobile 5579 + $(document).on('mousewheel', preventDefault);
  5580 + $(document).on('touchmove', preventDefault);
5527 } 5581 }
5528 5582
5529 function enableScroll() { 5583 function enableScroll() {
5530 - if (window.removeEventListener) {  
5531 - window.removeEventListener('DOMMouseScroll', preventDefault, false);  
5532 - }  
5533 - window.onmousewheel = document.onmousewheel = null;  
5534 - window.onwheel = null;  
5535 - window.ontouchmove = null;  
5536 - document.onkeydown = null; 5584 + var $choseArea = $('.chose-panel .main .chose-items');
  5585 +
  5586 + $choseArea.off('touchstart');
  5587 + $choseArea.off('touchmove');
  5588 + $choseArea.off('mousewheel');
  5589 +
  5590 + $(document).off('mousewheel', preventDefault);
  5591 + $(document).off('touchmove', preventDefault);
5537 } 5592 }
5538 5593
5539 //删除面板 5594 //删除面板
@@ -5584,10 +5639,12 @@ function show(html, cb) { @@ -5584,10 +5639,12 @@ function show(html, cb) {
5584 } 5639 }
5585 init(); 5640 init();
5586 } 5641 }
  5642 +
5587 $('.chose-panel').show(); 5643 $('.chose-panel').show();
5588 $num = $('#good-num'); 5644 $num = $('#good-num');
5589 cbFn = cb; 5645 cbFn = cb;
5590 5646
  5647 +
5591 disableScroll(); 5648 disableScroll();
5592 } 5649 }
5593 5650
This diff could not be displayed because it is too large.