开发者

Scrolling Frames for iPad

I am developing a web application that is going to be both IE9/HTML5 compatible and work on the iPad. The issue I'm running into is that I can't seem to get frames to scroll correctly (or at all) on the iPad while it works fine in a browser. I have tried both single finger scrolling and two-finger scrolling and all of the listed combinations below. Any help/ideas would be greatly appreciated.

(FYI: Telerik is a third party control library)

<telerik:RadSpl开发者_如何学Citter ID="radSplitter2" runat="server" Height="100%">
  <telerik:RadPane ID="RadPane2" runat="server" Scrolling="Both">
    <iframe width="100%" height="100%" scrolling="no" src="HTMLPage1.htm" />
  </telerik:RadPane>
</telerik:RadSplitter>

<telerik:RadSplitter ID="radSplitter3" runat="server" Height="100%">
  <telerik:RadPane ID="RadPane4" runat="server" Scrolling="Both" ContentUrl="HTMLPage1.htm">
  </telerik:RadPane>
</telerik:RadSplitter>

<telerik:RadSplitter ID="radSplitter4" runat="server" Height="100%">
  <telerik:RadPane ID="RadPane5" runat="server" Scrolling="Both">
    <div style="width:100%; overflow:auto">
      <iframe width="100%" height="100%" scrolling="no" src="HTMLPage1.htm" />
    </div>
  </telerik:RadPane>
</telerik:RadSplitter>

This code works but I really need to be able to include a page as a frame.

<telerik:RadSplitter ID="radSplitter1" runat="server" Height="100%">
  <telerik:RadPane ID="RadPane3" runat="server" Scrolling="Both">
    This Section Scrolls
    This Section Scrolls
    This Section Scrolls
    This Section Scrolls
    This Section Scrolls
    This Section Scrolls
  </telerik:RadPane>
</telerik:RadSplitter>


For iOS devices you need set overflow: auto; or the scrolling won't work. For my web apps I used fancybox to display iframes modally and once I change the overflow setting in the css file the two finger scroll worked perfectly on the iPad.


Would you check how it works with internal iframe(s) when Pane’s ContentUrl property is specified?

http://demos.telerik.com/aspnet-ajax/splitter/examples/externalcontentloading/defaultcs.aspx


The solution ended up being just forcing the frames to scroll using javascript:

just put this in place of your tag.

    <div id="scrollDiv" runat="server" style="position:relative; overflow:auto"></div>
    <iframe id="iFrame1" runat="server" style="display:none"></iframe>

    <script type="text/javascript" charset="utf-8">
        function initMobileScroll_<%= this.ClientID %>(ele) {
            var mobileScrollArea = document.getElementById(ele);

            mobileScrollArea.addEventListener('touchstart', function (event) {
                touchstart_<%= this.ClientID %>(event);
            });

            mobileScrollArea.addEventListener('touchmove', function (event) {
                touchmove_<%= this.ClientID %>(event);
            });

            // let’s set the starting point when someone first touches
            function touchstart_<%= this.ClientID %>(e) {
                startY = e.touches[0].pageY;
                startX = e.touches[0].pageX;
            }

            // calls repeatedly while the user’s finger is moving
            function touchmove_<%= this.ClientID %>(e) {
                var touches = e.touches[0];

                // override the touch event’s normal functionality
                e.preventDefault();

                // y-axis
                var touchMovedY = startY - touches.pageY;
                startY = touches.pageY; // reset startY for the next call
                mobileScrollArea.scrollTop = mobileScrollArea.scrollTop + touchMovedY;

                // x-axis
                var touchMovedX = startX - touches.pageX;
                startX = touches.pageX; // reset startX for the next call
                mobileScrollArea.scrollLeft = mobileScrollArea.scrollLeft + touchMovedX;
            }

        }

        var theFrame_<%= this.ClientID %> = document.getElementById('<%= iFrame1.ClientID %>');
        theFrame_<%= this.ClientID %>.onload = function () {
            var frameBody = theFrame_<%= this.ClientID %>.contentWindow.document.body.innerHTML;
            document.getElementById('<%= scrollDiv.ClientID %>').innerHTML = frameBody;
        }
        initMobileScroll_<%= this.ClientID %>('<%= scrollDiv.ClientID %>');
    </script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜