iPhone 4 und iPad 2 only Button

  • Hallo,
    da ja leider nur iPhone 4 und iPad 2 über einen Gyroscopesensor verfügen würde ich gerne nur bei diesen Geräten einen Button anzeigen lassen.
    Mit dem devices Parameter kann ich es zwar für iPhone und iPad regeln aber das betrifft ja dann auch ältere Versionen (iPad 1 und iPhone 3)...

    Hat jemand einen Tipp?

    Grüße aus Leipzig
    Marcus

  • Hi,

    eine echte Erkennung per Javascript ob es sich um ein iPad1 oder iPad2 handelt ist leider nicht möglich,
    es wäre zwar möglich z.B. zu erkennen ob Gryoscope-Unterstützung vorhanden ist, aber dann darauf auf ein iPad2 zu schließen wäre falsch, es könnte sich ja beispielsweise auch um ein iPad3 oder sonstiges neues iPad handeln...

    falls es aber nur um die Gryoscope Erkennung geht, dann könnte auch ein Code wie folgender verwendet werden - dieser verwendet den "available" Wert des Plugins (welche aber nach der Erkennung selbst zur Verfügung steht, deshalb das delayedcall):

    Code
    <plugin name="gyro" url="../../gyro.js" enabled="true" camroll="true" friction="0.5" velastic="0.2" devices="html5" keep="true"
            onloaded="delayedcall(1,ifnot(available, showgyrowarning()));"
    />

    dieser Code wird z.B. hier in diesem Beispiel verwendet:
    https://krpano.com/plugins/userpl…mples/gyro.html
    xml:
    https://krpano.com/plugins/userpl…amples/gyro.xml

    Schöne Grüße,
    Klaus

  • Hi,

    the answer is about how to detect the availability of the gryo sensor on the device:

    when the "available" variable of the plugin is "true" then the device has a gryo sensor,
    but it takes a bit until the plugin is setting that value, so the "delayedcall" before checking it,

    best regards,
    Klaus

  • Thanks for explaining this Klaus but could you help a little more please.

    Rather than popping up a warning I want to only make my gyro button appear if gyro is available and by default have it turned off on load.

    Currently I have this script for the button so that it can be turned on/off.

    Could you explain how your plugin and action would make this work please? *unsure*

  • Hi,

    just add an onloaded event to the gyro plugin and check there after a delayedcall the available variable,
    then e.g. when when available=true show your gyro button, and by default set your gyro button to invisible,

    e.g.

    Code
    <plugin name="gyro" ...
    onloaded="delayedcall(1,if(available, set(plugin[gyro-button].visible,true); ));"
    />
    
    
    <plugin name="gyro-button" ...
    	visible="false"
    />

    best regards,
    Klaus

  • Just to complicate this further, my client wants autorotate set true but that messes up the gyro. If I want to add a second command to the if statement how do I write it?

    Current code:

    Code
    onloaded="delayedcall(1,if(available, set(plugin[gyro-button].visible,true); ));"/>

    Does this look right? I can't test it as I dont have access to an iPad1.

    Code
    onloaded="delayedcall(1,if(available, set(plugin[gyro-button].visible,true); set(autorotate.enabled,false); ));"/>

    Will this override the default autorotate enabled="true" ?

    I really appreciate your help.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!