Showing
3 changed files
with
152 additions
and
114 deletions
@@ -1702,15 +1702,12 @@ var $ = require("jquery"), | @@ -1702,15 +1702,12 @@ var $ = require("jquery"), | ||
1702 | var start = 0, | 1702 | var start = 0, |
1703 | swiperClass, | 1703 | swiperClass, |
1704 | $logotrans = $('.home-header .logo'), | 1704 | $logotrans = $('.home-header .logo'), |
1705 | - $choseArea = $('.side-nav ul'), | ||
1706 | openSideNav = false, | 1705 | openSideNav = false, |
1707 | isen = true; | 1706 | isen = true; |
1708 | 1707 | ||
1709 | -var innerScroll = require("js/plugin/inner-scroll"); | ||
1710 | - | ||
1711 | lazyLoad($('img.lazy')); | 1708 | lazyLoad($('img.lazy')); |
1712 | 1709 | ||
1713 | -$('.nav-btn').on('touchstart', function(event) { | 1710 | +$('.nav-btn').on('touchstart', function() { |
1714 | $sideNav.css('pointer-events', 'none'); | 1711 | $sideNav.css('pointer-events', 'none'); |
1715 | $mobileWrap.addClass('menu-open'); | 1712 | $mobileWrap.addClass('menu-open'); |
1716 | $overlay.show().css('opacity', 0.3); | 1713 | $overlay.show().css('opacity', 0.3); |
@@ -1721,7 +1718,7 @@ $('.nav-btn').on('touchstart', function(event) { | @@ -1721,7 +1718,7 @@ $('.nav-btn').on('touchstart', function(event) { | ||
1721 | $sideNav.css('pointer-events', 'auto'); | 1718 | $sideNav.css('pointer-events', 'auto'); |
1722 | }, 400); | 1719 | }, 400); |
1723 | 1720 | ||
1724 | - innerScroll.disableScroll($choseArea); | 1721 | + //innerScroll.disableScroll($sideNav); |
1725 | 1722 | ||
1726 | return false; | 1723 | return false; |
1727 | }); | 1724 | }); |
@@ -1737,16 +1734,20 @@ function hideSideBar() { | @@ -1737,16 +1734,20 @@ function hideSideBar() { | ||
1737 | } | 1734 | } |
1738 | 1735 | ||
1739 | $('.overlay').on('touchstart', function(e) { | 1736 | $('.overlay').on('touchstart', function(e) { |
1740 | - innerScroll.enableScroll($choseArea); | ||
1741 | hideSideBar(); | 1737 | hideSideBar(); |
1742 | return false; | 1738 | return false; |
1743 | }); | 1739 | }); |
1744 | 1740 | ||
1741 | +$sideNav.on('touchmove', function(e) { | ||
1742 | + return false; | ||
1743 | +}); | ||
1744 | + | ||
1745 | // 点击一级导航,弹出二级导航 | 1745 | // 点击一级导航,弹出二级导航 |
1746 | $sideNav.on('touchend', 'li', function(e) { | 1746 | $sideNav.on('touchend', 'li', function(e) { |
1747 | if ($(this).find('.sub-nav').size() > 0) { | 1747 | if ($(this).find('.sub-nav').size() > 0) { |
1748 | $('.sub-nav').removeClass('show'); | 1748 | $('.sub-nav').removeClass('show'); |
1749 | $(this).find('.sub-nav').addClass('show'); | 1749 | $(this).find('.sub-nav').addClass('show'); |
1750 | + $(this).find('.highlight').removeClass('highlight'); | ||
1750 | } | 1751 | } |
1751 | 1752 | ||
1752 | if (e.target.pathname === location.pathname) { | 1753 | if (e.target.pathname === location.pathname) { |
@@ -1892,111 +1893,6 @@ exports.set = function(c) { | @@ -1892,111 +1893,6 @@ exports.set = function(c) { | ||
1892 | require("js/home/maybe-like")(); | 1893 | require("js/home/maybe-like")(); |
1893 | 1894 | ||
1894 | }); | 1895 | }); |
1895 | -define("js/plugin/inner-scroll", ["jquery"], function(require, exports, module){ | ||
1896 | -/** | ||
1897 | - * 弹出层可以滚动,遮盖层禁止滚动插件 | ||
1898 | - * | ||
1899 | - * @author liangzhifeng<zhifeng.liang@yoho.cn> | ||
1900 | - * @date: 2016/02/22 | ||
1901 | - */ | ||
1902 | - | ||
1903 | -var $ = require("jquery"); | ||
1904 | - | ||
1905 | -function preventDefault(e) { | ||
1906 | - e = e || window.event; | ||
1907 | - e.preventDefault && e.preventDefault(); | ||
1908 | - e.returnValue = false; | ||
1909 | -} | ||
1910 | - | ||
1911 | -function stopPropagation(e) { | ||
1912 | - e = e || window.event; | ||
1913 | - e.stopPropagation && e.stopPropagation(); | ||
1914 | - e.cancelBubble = false; | ||
1915 | -} | ||
1916 | - | ||
1917 | -function innerScroll(e) { | ||
1918 | - var delta = e.wheelDelta || e.originalEvent.wheelDelta || e.detail || 0, | ||
1919 | - box = $(this).get(0); | ||
1920 | - | ||
1921 | - // 阻止冒泡到document | ||
1922 | - // document上已经preventDefault | ||
1923 | - stopPropagation(e); | ||
1924 | - | ||
1925 | - | ||
1926 | - if ($(box).height() + box.scrollTop >= box.scrollHeight) { | ||
1927 | - if (delta < 0) { | ||
1928 | - preventDefault(e); | ||
1929 | - return false; | ||
1930 | - } | ||
1931 | - } | ||
1932 | - if (box.scrollTop === 0) { | ||
1933 | - if (delta > 0) { | ||
1934 | - preventDefault(e); | ||
1935 | - return false; | ||
1936 | - } | ||
1937 | - } | ||
1938 | -} | ||
1939 | - | ||
1940 | -function disableScroll($choseArea) { | ||
1941 | - var startX, startY; | ||
1942 | - | ||
1943 | - // 内部可滚 | ||
1944 | - $choseArea.on('mousewheel', innerScroll); | ||
1945 | - | ||
1946 | - // 移动端touch重写 | ||
1947 | - $choseArea.on('touchstart', function(e) { | ||
1948 | - startX = e.originalEvent.changedTouches[0].pageX; | ||
1949 | - startY = e.originalEvent.changedTouches[0].pageY; | ||
1950 | - }); | ||
1951 | - | ||
1952 | - // 仿innerScroll方法 | ||
1953 | - $choseArea.on('touchmove', function(e) { | ||
1954 | - var deltaX = e.originalEvent.changedTouches[0].pageX - startX, | ||
1955 | - deltaY = e.originalEvent.changedTouches[0].pageY - startY; | ||
1956 | - | ||
1957 | - var box = $(this).get(0); | ||
1958 | - | ||
1959 | - e.stopPropagation(); | ||
1960 | - | ||
1961 | - | ||
1962 | - // 只能纵向滚 | ||
1963 | - if (Math.abs(deltaY) < Math.abs(deltaX)) { | ||
1964 | - e.preventDefault(); | ||
1965 | - return false; | ||
1966 | - } | ||
1967 | - | ||
1968 | - | ||
1969 | - if ($(box).height() + box.scrollTop >= box.scrollHeight) { | ||
1970 | - if (deltaY < 0) { | ||
1971 | - e.preventDefault(); | ||
1972 | - return false; | ||
1973 | - } | ||
1974 | - } | ||
1975 | - if (box.scrollTop === 0) { | ||
1976 | - if (deltaY > 0) { | ||
1977 | - e.preventDefault(); | ||
1978 | - return false; | ||
1979 | - } | ||
1980 | - } | ||
1981 | - }); | ||
1982 | - | ||
1983 | - $(document).on('mousewheel', preventDefault); | ||
1984 | - $(document).on('touchmove', preventDefault); | ||
1985 | -} | ||
1986 | - | ||
1987 | -function enableScroll($choseArea) { | ||
1988 | - | ||
1989 | - $choseArea.off('touchstart'); | ||
1990 | - $choseArea.off('touchmove'); | ||
1991 | - $choseArea.off('mousewheel'); | ||
1992 | - | ||
1993 | - $(document).off('mousewheel', preventDefault); | ||
1994 | - $(document).off('touchmove', preventDefault); | ||
1995 | -} | ||
1996 | - | ||
1997 | -exports.enableScroll = enableScroll; | ||
1998 | -exports.disableScroll = disableScroll; | ||
1999 | -}); | ||
2000 | define("js/home/maybe-like", ["jquery","hammer","lazyload"], function(require, exports, module){ | 1896 | define("js/home/maybe-like", ["jquery","hammer","lazyload"], function(require, exports, module){ |
2001 | /** | 1897 | /** |
2002 | * “你可能喜欢”模块JS | 1898 | * “你可能喜欢”模块JS |
@@ -5760,8 +5656,6 @@ $yohoPage.on('touchstart', '.chose-panel', function(e) { | @@ -5760,8 +5656,6 @@ $yohoPage.on('touchstart', '.chose-panel', function(e) { | ||
5760 | //点击蒙版消失 | 5656 | //点击蒙版消失 |
5761 | hide(); | 5657 | hide(); |
5762 | 5658 | ||
5763 | - enableScroll(); | ||
5764 | - | ||
5765 | return false; | 5659 | return false; |
5766 | }); | 5660 | }); |
5767 | 5661 | ||
@@ -6039,6 +5933,111 @@ exports.disableNumEdit = disableNumEdit; | @@ -6039,6 +5933,111 @@ exports.disableNumEdit = disableNumEdit; | ||
6039 | 5933 | ||
6040 | 5934 | ||
6041 | }); | 5935 | }); |
5936 | +define("js/plugin/inner-scroll", ["jquery"], function(require, exports, module){ | ||
5937 | +/** | ||
5938 | + * 弹出层可以滚动,遮盖层禁止滚动插件 | ||
5939 | + * | ||
5940 | + * @author liangzhifeng<zhifeng.liang@yoho.cn> | ||
5941 | + * @date: 2016/02/22 | ||
5942 | + */ | ||
5943 | + | ||
5944 | +var $ = require("jquery"); | ||
5945 | + | ||
5946 | +function preventDefault(e) { | ||
5947 | + e = e || window.event; | ||
5948 | + e.preventDefault && e.preventDefault(); | ||
5949 | + e.returnValue = false; | ||
5950 | +} | ||
5951 | + | ||
5952 | +function stopPropagation(e) { | ||
5953 | + e = e || window.event; | ||
5954 | + e.stopPropagation && e.stopPropagation(); | ||
5955 | + e.cancelBubble = false; | ||
5956 | +} | ||
5957 | + | ||
5958 | +function innerScroll(e) { | ||
5959 | + var delta = e.wheelDelta || e.originalEvent.wheelDelta || e.detail || 0, | ||
5960 | + box = $(this).get(0); | ||
5961 | + | ||
5962 | + // 阻止冒泡到document | ||
5963 | + // document上已经preventDefault | ||
5964 | + stopPropagation(e); | ||
5965 | + | ||
5966 | + | ||
5967 | + if ($(box).height() + box.scrollTop >= box.scrollHeight) { | ||
5968 | + if (delta < 0) { | ||
5969 | + preventDefault(e); | ||
5970 | + return false; | ||
5971 | + } | ||
5972 | + } | ||
5973 | + if (box.scrollTop === 0) { | ||
5974 | + if (delta > 0) { | ||
5975 | + preventDefault(e); | ||
5976 | + return false; | ||
5977 | + } | ||
5978 | + } | ||
5979 | +} | ||
5980 | + | ||
5981 | +function disableScroll($choseArea) { | ||
5982 | + var startX, startY; | ||
5983 | + | ||
5984 | + // 内部可滚 | ||
5985 | + $choseArea.on('mousewheel', innerScroll); | ||
5986 | + | ||
5987 | + // 移动端touch重写 | ||
5988 | + $choseArea.on('touchstart', function(e) { | ||
5989 | + startX = e.originalEvent.changedTouches[0].pageX; | ||
5990 | + startY = e.originalEvent.changedTouches[0].pageY; | ||
5991 | + }); | ||
5992 | + | ||
5993 | + // 仿innerScroll方法 | ||
5994 | + $choseArea.on('touchmove', function(e) { | ||
5995 | + var deltaX = e.originalEvent.changedTouches[0].pageX - startX, | ||
5996 | + deltaY = e.originalEvent.changedTouches[0].pageY - startY; | ||
5997 | + | ||
5998 | + var box = $(this).get(0); | ||
5999 | + | ||
6000 | + e.stopPropagation(); | ||
6001 | + | ||
6002 | + | ||
6003 | + // 只能纵向滚 | ||
6004 | + if (Math.abs(deltaY) < Math.abs(deltaX)) { | ||
6005 | + e.preventDefault(); | ||
6006 | + return false; | ||
6007 | + } | ||
6008 | + | ||
6009 | + | ||
6010 | + if ($(box).height() + box.scrollTop >= box.scrollHeight) { | ||
6011 | + if (deltaY < 0) { | ||
6012 | + e.preventDefault(); | ||
6013 | + return false; | ||
6014 | + } | ||
6015 | + } | ||
6016 | + if (box.scrollTop === 0) { | ||
6017 | + if (deltaY > 0) { | ||
6018 | + e.preventDefault(); | ||
6019 | + return false; | ||
6020 | + } | ||
6021 | + } | ||
6022 | + }); | ||
6023 | + | ||
6024 | + $(document).on('mousewheel', preventDefault); | ||
6025 | + $(document).on('touchmove', preventDefault); | ||
6026 | +} | ||
6027 | + | ||
6028 | +function enableScroll($choseArea) { | ||
6029 | + | ||
6030 | + $choseArea.off('touchstart'); | ||
6031 | + $choseArea.off('touchmove'); | ||
6032 | + $choseArea.off('mousewheel'); | ||
6033 | + | ||
6034 | + $(document).off('mousewheel', preventDefault); | ||
6035 | + $(document).off('touchmove', preventDefault); | ||
6036 | +} | ||
6037 | + | ||
6038 | +exports.enableScroll = enableScroll; | ||
6039 | +exports.disableScroll = disableScroll; | ||
6040 | +}); | ||
6042 | define("js/product/detail/desc", ["jquery","lazyload","swiper","index"], function(require, exports, module){ | 6041 | define("js/product/detail/desc", ["jquery","lazyload","swiper","index"], function(require, exports, module){ |
6043 | /** | 6042 | /** |
6044 | * 商品详情 --异步加载页面下半部分 | 6043 | * 商品详情 --异步加载页面下半部分 |
@@ -8270,7 +8269,8 @@ define("js/me/index", ["jquery","swiper","index"], function(require, exports, mo | @@ -8270,7 +8269,8 @@ define("js/me/index", ["jquery","swiper","index"], function(require, exports, mo | ||
8270 | * @author: bikai<kai.bi@yoho.cn> | 8269 | * @author: bikai<kai.bi@yoho.cn> |
8271 | * @date: 2015/11/12 | 8270 | * @date: 2015/11/12 |
8272 | */ | 8271 | */ |
8273 | -var $ = require("jquery"); | 8272 | +var $ = require("jquery"), |
8273 | + noticeScroll = require("js/plugin/notice-scroll"); | ||
8274 | var $userAvatar = $('.user-avatar'), | 8274 | var $userAvatar = $('.user-avatar'), |
8275 | $listItem = $('.list-item'); | 8275 | $listItem = $('.list-item'); |
8276 | var myImage = new Image(), | 8276 | var myImage = new Image(), |
@@ -8286,6 +8286,8 @@ myImage.onload = function() { | @@ -8286,6 +8286,8 @@ myImage.onload = function() { | ||
8286 | $userAvatar.css('background-image', 'url(' + avatar + ')'); | 8286 | $userAvatar.css('background-image', 'url(' + avatar + ')'); |
8287 | }; | 8287 | }; |
8288 | 8288 | ||
8289 | +noticeScroll('.notice'); | ||
8290 | + | ||
8289 | $('.yoho-page').on('touchstart', '.list-item, .type-item, .order-title', function() { | 8291 | $('.yoho-page').on('touchstart', '.list-item, .type-item, .order-title', function() { |
8290 | $listItem.removeClass('highlight'); | 8292 | $listItem.removeClass('highlight'); |
8291 | $(this).addClass('highlight'); | 8293 | $(this).addClass('highlight'); |
@@ -8294,6 +8296,38 @@ $('.yoho-page').on('touchstart', '.list-item, .type-item, .order-title', functio | @@ -8294,6 +8296,38 @@ $('.yoho-page').on('touchstart', '.list-item, .type-item, .order-title', functio | ||
8294 | }); | 8296 | }); |
8295 | 8297 | ||
8296 | }); | 8298 | }); |
8299 | +define("js/plugin/notice-scroll", ["jquery"], function(require, exports, module){ | ||
8300 | +/** | ||
8301 | + * 公告栏目滚动 | ||
8302 | + * bikai kai.bi@yoho.cn | ||
8303 | + */ | ||
8304 | + | ||
8305 | +var $ = require("jquery"); | ||
8306 | + | ||
8307 | +function noticeScroll(selecter, time) { | ||
8308 | + var $notice = $(selecter), | ||
8309 | + $noticeItem = $notice.find('.notice-item'), | ||
8310 | + count = $noticeItem.length, | ||
8311 | + i = 1; | ||
8312 | + | ||
8313 | + selecter = selecter || '.notice'; | ||
8314 | + time = time || 3000; | ||
8315 | + | ||
8316 | + if (count > 1) { | ||
8317 | + setInterval(function() { | ||
8318 | + if (i >= count) { | ||
8319 | + i = 0; | ||
8320 | + } | ||
8321 | + $noticeItem.fadeOut(); | ||
8322 | + $notice.find('.item-' + i).fadeIn(); | ||
8323 | + i++; | ||
8324 | + }, time); | ||
8325 | + } | ||
8326 | +} | ||
8327 | + | ||
8328 | +module.exports = noticeScroll; | ||
8329 | + | ||
8330 | +}); | ||
8297 | define("js/product/recommend-for-you", ["swiper","jquery","index"], function(require, exports, module){ | 8331 | define("js/product/recommend-for-you", ["swiper","jquery","index"], function(require, exports, module){ |
8298 | /** | 8332 | /** |
8299 | * 为您优选 | 8333 | * 为您优选 |
@@ -9344,6 +9378,10 @@ $('.btn-balance').on('touchend', function() { | @@ -9344,6 +9378,10 @@ $('.btn-balance').on('touchend', function() { | ||
9344 | } | 9378 | } |
9345 | }); | 9379 | }); |
9346 | 9380 | ||
9381 | +$('.off-shell-goods .shopping-cart-good').on('touchend', function() { | ||
9382 | + tip.show('商品已下架'); | ||
9383 | +}); | ||
9384 | + | ||
9347 | $('.chose').on('touchend', function() { | 9385 | $('.chose').on('touchend', function() { |
9348 | chosePanel.show(); | 9386 | chosePanel.show(); |
9349 | }); | 9387 | }); |
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
-
Please register or login to post a comment