Coder Social home page Coder Social logo

ensureVisible ? about angular-winjs HOT 5 CLOSED

winjs avatar winjs commented on September 25, 2024
ensureVisible ?

from angular-winjs.

Comments (5)

jayrenn avatar jayrenn commented on September 25, 2024

@sensiblearts Can you provide a repro of your code? You should be able to use the indexOfFirstVisible property to get the first visible item (or set, if you wish to jump to a particular item).

from angular-winjs.

sensiblearts avatar sensiblearts commented on September 25, 2024

@jayrenn , @AmazingJaze , Basically, I'm loading listview data in $scope.init and trying to time when to scroll to the right object.


   $scope.backToTab = function() {
           // code omitted here, switches to the tab with the listview
           if (item_index) {  // e.g., 7 to scroll to 7th item
                   var list_v = document.getElementsByClassName("win-listview");
                   if (list_v.length) {
                       list_v = list_v[0].winControl;
                       if (list_v) {
                           //not working:
                           list_v.indexOfFirstVisible = item_index;
                           console.log(list_v.indexOfFirstVisible); //  -1 or 0, regardless of what I set it to
  
                           // or if I add another timeout delay here, I get error as in my previous post
 
                        }
                    }
               }
           }
        };
        $scope.init = function () {
             $http.get('api/mygroups',{broadcastError:true}).
                  success(function(data, status, headers, config) {
                    $scope.groups = data.groups || [];   // data for listview
                    //...
                    $timeout( $scope.backToTab, 100);  // see above
                  }).
                  error(function(data, status, headers, config) {
                  });
         };
  

from angular-winjs.

AmazingJaze avatar AmazingJaze commented on September 25, 2024

Hi @sensiblearts , thanks for the additional information. Just to clarify, are you only seeing this problem when trying to navigate back to a ListView that was already rendered? Or do you see this problem the first time a ListView is constructed and are unable to get ensureVisible() to work correctly even then?

When the problem occurs, does the ListView element have proper dimensions when you are setting the data or trying to call ensureVisible() ? If the ListView element can not accurately measure itself and its items, for example. due to a parent element having display:none; , then you might find that calling ListView.forceLayout() or the less expensive ListView.recalculateItemPosition(), once the element once again has proper dimensions, may rectify this problem for you.

Finally, I see that you are using document.getElementsByClassName("win-listview")[0] to get a hold of the listview element, is it possible that the element at index 0 is not actually the correct listview element? Out of curiosity what is the length of the array that getElementsByClassName is returning when that code is executed?

If none of the above addresses your issue, can you share a page or app that repros the bug? If you want to send us files, you can use OneDrive as described in our described in our wiki.

from angular-winjs.

AmazingJaze avatar AmazingJaze commented on September 25, 2024

Edited my previous response for extra clarification.

from angular-winjs.

sensiblearts avatar sensiblearts commented on September 25, 2024

Thank you so much for the detailed reply.

I built a test app by stripping out unrelated code, and (probably no
surprise to you), indexOfFirstVisible works as it is supposed to!

I will figure out what in my full app is causing the side effect, and I
will pass along the information just in case it is relevant to your efforts.

D. Alm

On Wed, Jul 29, 2015 at 7:56 PM, AmazingJaze [email protected]
wrote:

Hi @sensiblearts https://github.com/sensiblearts , thanks for the
additional information. Just to clarify, are you only seeing this problem
when trying to navigate back to a ListView that was already rendered? Or do
you see this problem the first time a ListView is constructed and are
unable to get ensureVisible() to work correctly?

When the problem occurs, does the ListView element have proper dimensions
when you are setting the data or trying to call ensureVisible() ? If the
ListView element can not accurately measure itself and its items, for
example. due to a parent element having display:none; , then you might find
that calling ListView.forceLayout() or the less expensive
ListView.recalculateItemPosition may rectify this problem for you.

Finally, I see that you are using
document.getElementsByClassName("win-listview")[0] to get a hold of the
listview element, is it possible that the element at index 0 is not
actually the correct listview element? Out of curiosity what is the length
of the array that getElementsByClassName is returning when that code is
executed?

If none of the above addresses your issue, can you share a page or app
that repros the bug? If you want to send us files, you can use OneDrive as
described in our described in our wiki
https://github.com/winjs/winjs/wiki/How-to-share-repros-of-issues-with-WinJS
.


Reply to this email directly or view it on GitHub
#53 (comment).

</>
David Alm

from angular-winjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.