Layering Mobile Controls
Pierre Sahores
sc at sahores-conseil.com
Sat Mar 2 16:39:22 EST 2013
Hi Ender Nafi,
Use one browser object only and to refresh it with one of the different contents to be displayed alternatively, put and adapt this JS script at the bottom of your html source code :
> <script type="text/javascript">
> var priogesture = 1, start_x = 0, stop_x = 0, start_y = 0, stop_y = 0;
> function $(id) { return document.getElementById(id); }
> $("zoom").addEventListener ("gesturestart", function (event) { priogesture = 1 });
> $("zoom").addEventListener ("gesturechange", function (event) { priogesture = 1 });
> $("zoom").addEventListener ("gestureend", function (event) { priogesture = 1 });
> $("zoom").addEventListener ("touchstart", function (event) {
> start_x = event.touches[0].screenX; start_y = event.touches[0].screenY; priogesture = 0;
> });
> $("zoom").addEventListener ("touchmove", function (event) {
> stop_x = event.touches[0].screenX; stop_y = event.touches[0].screenY;
> if ((priogesture == 0) && (stop_x != 0) && (Math.abs(stop_x - start_x) > Math.abs(stop_y - start_y))) {
> if (start_x < stop_x) {
> document.location.href="file:/data/data/yourmobileappid/cache/prev.html";
> } else if (start_x > stop_x) {
> document.location.href="file:/data/data/yourmobileappid/cache/next.html";
> }
> }
> });
> /* $("zoom").addEventListener ("touchend", function (event) { }); */
> </script>
and use the pseudo-files "prev.html" and "next.html" (both empty files) as callback's entry points to your livecode switch contents dedicated scripting :
against the iOS platform :
> on browserLoadRequested pUrl, pType
> if the platform is "iPhone" then
> if "/cache/prev.html" is in pURL
> then goPrevGaleryScreen
> else if "/cache/next.html" is in pURL
> then goNextGaleryScreen
> end if
> end browserLoadRequested
against the Android platform :
> on browserStartedLoading pUrl
> if "/cache/prev.html" is in pURL and the platform is "android" then
> goPrevGaleryScreen
> else if "/cache/next.html" is in pURL and the platform is "android" then
> goNextGaleryScreen
> end browserStartedLoading
HTH,
Pierre
Le 2 mars 2013 à 21:02, Ender Nafi Elekçioğlu a écrit :
> Hi all,
>
>
> Is there any workaround to use two different mobile controls whose "rect" properties are same?
> Here is the case:
> I have three fullscreen browser controls {created by *mobileControlCreate "browser"* command},
> the left and right controls are outside of the screen {something like this: http://cloud.keehuna.com/image/3c0i0z0t2F1E}
>
> And I want to switch between them via a native scroller {created by *mobileControlCreate "scroller"* command},
> my code is something like this:
>
> on scrollerDidScroll pX, pY
> __switch mobileControlTarget()
> ____case "theScroller"
> ________/* you should reverse the direction and get rid of static values */
> ______put (pX - 960) & comma & 40 & comma & (pX - 480) & comma & 280 into tRectL
> ______put (pX - 480) & comma & 40 & comma & pX & comma & 280 into tRectC
> ______put pX & comma & 40 & comma & (pX + 480) & comma & 280 into tRectR
> _
> ______set the text of field "scrollValues" to pX & " - " & pY & return & tRectL && tRectC && tRectR
> _
> ______mobileControlSet "theBrowserL", "rect", tRectL
> ______mobileControlSet "theBrowserC", "rect", tRectC
> ______mobileControlSet "theBrowserR", "rect", tRectR
> ______break
> __end switch
> end scrollerDidScroll
>
>
>
> Well, of course it doesn't work because the browser control is blocking the scroller control.
> The touch events can't pass through the browser and reach to the scroller.
>
> I can always squeeze the browser control's height and leave some space at the bottom to the scroller.
> But it's a very bad design both from a visual and functional perspective.
>
> Another method is not to use the scroller control
> and inject jqueryMobile and an appropriate swipe command into the html file via script.
> But this method works only on local html files not with online webpages.
>
>
> Any insights & thoughts about this?
>
>
> Best,
>
> ~ Ender Nafi
>
>
>
> ~ · Keehuna Studio
> ~ · Sorcerers of Design
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
--
Pierre Sahores
mobile : 06 03 95 77 70
www.sahores-conseil.com
More information about the use-livecode
mailing list