1234567891011121314151617181920212223242526272829303132333435 |
- /*
- * @Description:
- * @Author: Napier
- * @LastEditors: Napier
- * @LastEditorTime:
- */
- export default {
- fun: function () {
- var overscroll = function (el) {
- el.addEventListener('touchstart', function () {
- var top = el.scrollTop
- var totalScroll = el.scrollHeight
- var currentScroll = top + el.offsetHeight
- if (top === 0) {
- el.scrollTop = 1
- } else if (currentScroll === totalScroll) {
- el.scrollTop = top - 1
- }
- })
- el.addEventListener('touchmove', function (evt) {
- if (el.offsetHeight < el.scrollHeight) {
- evt._isScroller = true
- }
- })
- }
- overscroll(document.querySelector('.scroll'))
- document.body.addEventListener('touchmove', function (evt) {
- if (!evt._isScroller) {
- evt.preventDefault()
- }
- })
- }
- }
|