locked
Help! Pointer Animations

    Question

  • hi all

    I need a little help on pointer animations

    Here is the homePage.js code im using

    (function () {
        function id(elementId) {
            return document.getElementById(elementId);
        }
        function onPointerDown(event) {
            WinJS.UI.Animation.pointerDown(event.srcElement);
        }
        function onPointerUp(event) {
            WinJS.UI.Animation.pointerUp(event.srcElement);
        }
    
        function initializeAnimation() {
                <strong>id("a").</strong>addEventListener("MSPointerDown", onPointerDown, false);
            <strong>id("a").</strong>addEventListener("MSPointerUp", onPointerUp, false);
        }
        function initialize() {
            initializeAnimation();
        }
        document.addEventListener("DOMContentLoaded", initialize, false);
    }
    )();
    

    and here is homePage.html that contains a single div that should animate on pointerdown and up events.

    <div class="div1" id="a">Test Div</div>

    But it doesnt work at all. Am I missing something?because this same code works well on default.html and default.js why it isnt working on homePage.html and homePage.js?is there different method?


    Sunday, January 22, 2012 10:32 AM

Answers

  • Hi Arsian,

    The debugger is your friend! Load your project and debug it setting breakpoints in homepage.js.  You will see your code is never called. 

    To fix this remove type="ms-deferred/javascript" from homepage.html

    You will want to use ms-deferred only of your page is loaded as a fragment.

    -Jeff

     


    Jeff Sanders (MSFT)
    Wednesday, January 25, 2012 6:35 PM
    Moderator

All replies

  • Hi Arsian,

    Perhaps you are picking up the wrong div.  Try using class selectors or a different id for the div on homePage.html (id = "b").

    -Jeff

     


    Jeff Sanders (MSFT)
    Monday, January 23, 2012 4:00 PM
    Moderator
  • hi

    I have tried different id as well. What about "DOMContentLoaded" thing?Will it be same for default.html and homePage.html?

    Only thing that bothers me is that this same code and div works on default.html and default.js so whats so special in homePage.html and homePage.js that prevents the execution?

    There are only two things in this code that can be wrong. One is div id, ie id="a" or "b" or anything. Other is "DOMContentLoaded" thing that I dont know in much detail because im new to javascripting.

    So div id cant be wrong because I checked it several times.  "DOMContentLoaded" thing might be right for default.html but not for homePage.html.

    I will keep trying myself and will appreciate any help or suggestions.

    Thanks for your reply, Jeff.

    Tuesday, January 24, 2012 12:35 PM
  • Can you send me a simple Repro of this?

    Email me here and I will reply:

    http://blogs.msdn.com/b/jpsanders/contact.aspx

     


    Jeff Sanders (MSFT)
    Tuesday, January 24, 2012 3:53 PM
    Moderator
  • Email sent!

    Tuesday, January 24, 2012 7:27 PM
  • Hi Arsian,

    The debugger is your friend! Load your project and debug it setting breakpoints in homepage.js.  You will see your code is never called. 

    To fix this remove type="ms-deferred/javascript" from homepage.html

    You will want to use ms-deferred only of your page is loaded as a fragment.

    -Jeff

     


    Jeff Sanders (MSFT)
    Wednesday, January 25, 2012 6:35 PM
    Moderator
  • Problem Solved!

    Thanks!

    Wednesday, January 25, 2012 6:37 PM