Yahoo yui 和 iPad 方向

发布于 2024-10-29 20:44:51 字数 782 浏览 2 评论 0原文

我刚刚开始为 iPad 开发一些类似 Web 应用程序的网站。我使用 YUI 的滚动视图来显示列表,效果很好。

现在的问题是,当方向改变时,我必须更新滚动器实例的高度,但我不知道如何完成。

据我所知,在我凌乱的代码中应该有一些侦听器和事件参数或其他东西。有什么想法吗?

YUI().use("scrollview", function (Y) {


  if(window.orientation == 0) // Temp solution to set the right height on load.
        { var iheight = 740; }
    else if(window.orientation == 90 || window.orientation == -90)
        { var iheight = 480; }

    var scrollview = new Y.ScrollView({
        id: "scrollview",
        srcNode: '#scrollable',
        height: iheight,        
        flick: {
            minDistance:10,
            minVelocity:0.3,
            axis: "y"}
    });

    scrollview.render();

    scrollView._uiDimensionsChange(); // Think I'm supposed to use this somehow.
});

I've just started developing some web application-like sites for iPad. I'm using YUI's scrollView for lists, which works nicely.

Now the problem is that when the orientation changes, I've got to update the scroller-instance's height, which I havn't got a clue how to accomplish.

As far sa I know, there should be some listeners and event args or something in my messy piece of code. Any ideas?

YUI().use("scrollview", function (Y) {


  if(window.orientation == 0) // Temp solution to set the right height on load.
        { var iheight = 740; }
    else if(window.orientation == 90 || window.orientation == -90)
        { var iheight = 480; }

    var scrollview = new Y.ScrollView({
        id: "scrollview",
        srcNode: '#scrollable',
        height: iheight,        
        flick: {
            minDistance:10,
            minVelocity:0.3,
            axis: "y"}
    });

    scrollview.render();

    scrollView._uiDimensionsChange(); // Think I'm supposed to use this somehow.
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

没︽人懂的悲伤 2024-11-05 20:44:51

要更改高度,您需要做的就是:

scrollView.setAttrs({height: 500});

要在方向更改时执行该代码,这应该可以工作(尽管我无法测试它,因为我不在移动浏览器上) :

YUI().use("scrollview", function (Y) {

    function getHeight() {
        switch (window.orientation) {
            case 0:
                return 740;
            case 90:
            case -90:
                return 480;
            default:
                return ???;
        }
    }

    var scrollview = new Y.ScrollView({
        id: "scrollview",
        srcNode: '#scrollable',
        height: getHeight(),        
        flick: {
            minDistance:10,
            minVelocity:0.3,
            axis: "y"}
    });

    scrollview.render();

    Y.on("orientationchange", function (e) {
    {
        scrollView.setAttrs({
            height: getHeight()
        });
    });
});

To change the height, all you need to do is this:

scrollView.setAttrs({height: 500});

To execute that code when the orientation changes, this should work (though I can't test it since I'm not on a mobile browser):

YUI().use("scrollview", function (Y) {

    function getHeight() {
        switch (window.orientation) {
            case 0:
                return 740;
            case 90:
            case -90:
                return 480;
            default:
                return ???;
        }
    }

    var scrollview = new Y.ScrollView({
        id: "scrollview",
        srcNode: '#scrollable',
        height: getHeight(),        
        flick: {
            minDistance:10,
            minVelocity:0.3,
            axis: "y"}
    });

    scrollview.render();

    Y.on("orientationchange", function (e) {
    {
        scrollView.setAttrs({
            height: getHeight()
        });
    });
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文