1. #1
    Sencha User shinriyo's Avatar
    Join Date
    Nov 2011
    Posts
    76
    Vote Rating
    0
    shinriyo is on a distinguished road

      0  

    Default I resolved non-onload problem when back via safari in iPhone

    I resolved non-onload problem when back via safari in iPhone


    iPhone can't DO onload when back page via safari.
    So, I can't click.

    But, I found how to add listener again though back prev page.

    Code:
            function addListenerTo(element, event, aFunction) {
    
    /*
                element.addEventListener(event, function(event){
                    aFunction(me,event);
                }, false);
    */
                // adding listener by 1s
                setInterval(function() { element.addEventListener(event, function(event){ aFunction(me,event); }, false) }, 1000);
            }
    but... I'm afraid adding a lot listeners.

  2. #2
    Sencha User arnebech's Avatar
    Join Date
    Jun 2010
    Posts
    498
    Vote Rating
    10
    arnebech will become famous soon enough

      0  

    Default


    I am not fully sure what you are trying to accomplish.
    Can you describe the issue more and show the relevant code?

  3. #3
    Sencha User shinriyo's Avatar
    Join Date
    Nov 2011
    Posts
    76
    Vote Rating
    0
    shinriyo is on a distinguished road

      0  

    Default


    Hi arnebech

    It is the problem of iPhone safari.

    In the situation from A page to B page.
    back.png
    A is the page developed by Sencha Animator.

    I attached click event to AN-sObj-42 button.
    Code:
    window.addEventListener('load', function(){
    
    
    
    
        var configData = {
            parentId: 'AN-sObj-parentOl',
            ormma: false,
            scenes: [{id: 0,animationCount: 14,duration: 3800,dimensions: {height: 320,width: 320,expanded: false,fit: false}}],
            clickEvents: [{id: "AN-sObj-42",handler: function(controller) {
            linkConvert();
    }}]
        };
        AN.Controller.setConfig(configData);
    }, false);
    when I go to B page from A page.
    And I touch prev button of safari.

    load event can't run!!
    Code:
    window.addEventListener('load', function(){
    so, it doesn't run!
    Code:
        setupListeners: function() {
            var me = this;
            
            var eventName = "webkitAnimationEnd";
    
    
            if (document.body.style.MozAnimationName !== undefined) {
                eventName = "animationend";
                this.browser = "moz";
            }
    
    
            this.olElement.addEventListener(eventName, function() {
                me.onAnimationEnd();
            },false);
            
            function addMousemoveListenerTo(scene) {
                scene.element.addEventListener('mousemove', function(event){
                    scene.mousemoveAction(me, event);
                }, false);
            }
            
            var scene;
            for (var i=0; i < this.scenesArray.length; i++) {
                scene = this.scenesArray[i];
                if (scene.mousemoveAction) {
                    
                    addMousemoveListenerTo(scene);
                }
            }
            /* it didn't run! */
            function addListenerTo(element, event, aFunction) {
                element.addEventListener(event, function(event){
                    aFunction(me,event);
                }, false);
    
    
            }
            
            //add click events
            var element, clickEvent;
            for (var i=0; i < this.clickEvents.length; i++) {
                clickEvent = this.clickEvents[i];
                element = document.getElementById(clickEvent.id);
                addListenerTo(element, 'click', clickEvent.handler);
            }
            
        },
    I fix below and I resolved.
    Code:
           function addListenerTo(element, event, aFunction) {
    
    
    /*
                element.addEventListener(event, function(event){
                    aFunction(me,event);
                }, false);
    */
                // adding listener by 1s
                setInterval(function() { element.addEventListener(event, function(event){ aFunction(me,event); }, false) }, 1000);
            }
    but, I'm afraid if the addEventListener increacing.

  4. #4
    Sencha User arnebech's Avatar
    Join Date
    Jun 2010
    Posts
    498
    Vote Rating
    10
    arnebech will become famous soon enough

      0  

    Default


    So if I understand you correctly, when you got back in Safari the animation won't load, because the 'load' event is never fired?

    Could you check what the document state is when the load event is attached? And when/if the load event is fired?

    e.g.

    Code:
    alert(document.readyState);
    window.addEventListener('load', function(){
        alert('load run state: ' + document.readyState);
         .....
    }

  5. #5
    Sencha User shinriyo's Avatar
    Join Date
    Nov 2011
    Posts
    76
    Vote Rating
    0
    shinriyo is on a distinguished road

      0  

    Default


    Hi arnebech

    >So if I understand you correctly, when you got back in Safari the animation won't load, because the 'load' event is never fired?

    Yes.
    Safari never fire load event when I back to prev page.

    >Could you check what the document state is when the load event is attached? And when/if the load event is fired?

    I tried your code.
    Before backing, it is appeared.
    --
    loading
    load run state:complete
    ---

    But, when touch button later buck to prev page, it is never appeared.

  6. #6
    Sencha User arnebech's Avatar
    Join Date
    Jun 2010
    Posts
    498
    Vote Rating
    10
    arnebech will become famous soon enough

      0  

    Default


    Could you PM me a link or the exported project, so I could try it out?

  7. #7
    Sencha User shinriyo's Avatar
    Join Date
    Nov 2011
    Posts
    76
    Vote Rating
    0
    shinriyo is on a distinguished road

      0  

    Default I will send you later

    I will send you later


    Hi arnebech

    I found how to attach only one Listener.

    I delete classified information and will send you PM later.

  8. #8
    Sencha User shinriyo's Avatar
    Join Date
    Nov 2011
    Posts
    76
    Vote Rating
    0
    shinriyo is on a distinguished road

      0  

    Default


    Hi arnebech

    I'm sorry.
    I put the animation on the social game platform.
    The social game platform avoid the animation.
    It is not Sencha Animator problem.

  9. #9
    Sencha User arnebech's Avatar
    Join Date
    Jun 2010
    Posts
    498
    Vote Rating
    10
    arnebech will become famous soon enough

      0  

    Default


    As long as you only are attaching one handler you should be good. I tried to reproduce your issue, but was not able to, but sounds like you have it working now as well.

Thread Participants: 1