Code Monkey home page Code Monkey logo

Comments (12)

cq-z avatar cq-z commented on July 4, 2024

下拉列表在后退的时候无法定位之前下拉位置,在苹果浏览器后退不会执行JS,但是在其他chrome后退会执行JS。导致位置重置。这个问题目前用startY来决绝。MUI是否能解决这个问题

from mui.

fxy060608 avatar fxy060608 commented on July 4, 2024

没明白是什么意思

from mui.

cq-z avatar cq-z commented on July 4, 2024

例子:我类表有11个项,我下拉到最后一个位置。点击项目详情,看完后返回。这个时候列表又回到列表头部,没有保留跳转前的位置。

from mui.

cq-z avatar cq-z commented on July 4, 2024

这个影响用户体验。

from mui.

fxy060608 avatar fxy060608 commented on July 4, 2024

你是说点击后退之后?
如果是在5+环境,可以使用预加载机制,预加载该下拉刷新窗口,这样的话,后退不会关闭下拉刷新窗口,而是隐藏。再打开,是直接显示,这样就可以保证下拉所处的位置不变。
可以测试我们的hello-mui里的下拉刷新,后退再进去,位置是不变的

from mui.

cq-z avatar cq-z commented on July 4, 2024

好吧。我用的是WAP项目。呵呵openwinods体验不好。了解了谢谢了!

from mui.

fxy060608 avatar fxy060608 commented on July 4, 2024

浏览器环境的话,需要你自己实现。比如cookie记录当前位置。下次进入后,自动滚动到当前位置

from mui.

cq-z avatar cq-z commented on July 4, 2024

目前是在2126行的//API setTranslate方法保存Y值。框架没设置回调方法,只能修改MUI的JS来实现
然后初始化的时候传入startY

from mui.

fxy060608 avatar fxy060608 commented on July 4, 2024

不需要改源码,监听scrollend事件。e.detail是当前的scroll对象。直接获取y值即可

document.getElementById("scroll").addEventListener('scrollend', function(e) {
                        console.log(e.detail.y);
                    });

from mui.

cq-z avatar cq-z commented on July 4, 2024

太感谢了。之前就是尝试各种方法都监听不到Y值。无奈就改源码。测试OK了才过来发问题。

from mui.

fxy060608 avatar fxy060608 commented on July 4, 2024

因为scrollend可能触发非常频繁,所以建议不要在scrollend里边添加比较复杂的代码,比如直接操作cookie。而是把e.detail.y值赋给一个全局y值。然后通过定时事件检查y值是否变化,然后设置cookie。
示例代码

                                        var y = 0;
                    var lastY = 0;
                    window.setInterval(function() {
                        if (y != lastY) {
                            //TODO 将y存储到cookie
                            lastY = y;
                        }
                    }, 100);
                    document.getElementById("scroll").addEventListener('scrollend', function(e) {
                        y = e.detail.y;
                    });

from mui.

cq-z avatar cq-z commented on July 4, 2024

我是存到window.history.replaceState,来实现多个拉下页面切换后多次返回结果的存储。谢谢大神解惑!

from mui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.