GithubHelp home page GithubHelp logo

Comments (5)

Qvatra avatar Qvatra commented on August 16, 2024

I did figure out that I can do it by asking it in matrices:

    var offset_x = flexScrollView._dataSource[id]._matrix[12];
    var offset_y = flexScrollView._dataSource[id]._matrix[13];

which works but I also need to know the flexScrollView absolute offset.
For some reason flexScrollView.getOffset() doesn't show absolute offset of a view. I don't know what it shows.. seems like it resets after whole page was scrolled and strarts over..

How to get absolute offset?

Also I would like to know is there a way to disable scrolling dynamically?

from famous-flex.

IjzerenHein avatar IjzerenHein commented on August 16, 2024

Yikes!

If you want to offset a renderable, I suggest you wrap it inside Modifier, and give the Modifier a translation offset:

var RenderNode = require('famous/core/RenderNode');
var Surface = require('famous/core/Surface');
var Modifier = require('famous/core/Modifier');
var Transform = require('famous/core/Transform');

// Create a surface that is offsetted 10px down
var mod = new Modifier({
  transform: Transform.translate(0, 10, 0)
});
var sur = new Surface({..});
var node = new RenderNode(mod);
node.add(sur);

// Add surface to scrollview
scrollView.push(node);

To answer your other question. You can use the getSpec function to get the absolute position of a renderable. This only works though if the renderable is in the DOM.

from famous-flex.

IjzerenHein avatar IjzerenHein commented on August 16, 2024

Btw, this method:

var offset_x = flexScrollView._dataSource[id]._matrix[12];
var offset_y = flexScrollView._dataSource[id]._matrix[13];

Don't use it. You are accessing private members of the FlexScrollView and Surface. These will possibly change in a future update causing your code to break.

from famous-flex.

Qvatra avatar Qvatra commented on August 16, 2024

Goedendag,
here is example of what I want to build: https://dl.dropboxusercontent.com/u/49691996/FamousDemo/kit/examples/views/flexScrollCenter/example.html

onclick event should move red surface to the upper left corner independently of the position of the scroll.
I'm use here private members:
var offset_x = flexScrollView._dataSource[3]._matrix[12];
var offset_y = flexScrollView._dataSource[3]._matrix[13];
var absoluteScrollPosition = flexScrollView._scroll.groupStart + flexScrollView.getOffset();

I really don't know how to get these values in a right way.... Can you help me?

  1. I can't use getSpec because my red surface doesn't have it.
  2. In documentation is said that flexScrollView.getOffset() is the scroll position of the flexscrollview but I've found out that its not absolute - if you have a lot of elements offset resets continuously while scrolling (after each reset scroll.groupStart collects that value so I've found a way to get absolute position)
  3. Is it possible to disable scrolling after onclick event?

from famous-flex.

Qvatra avatar Qvatra commented on August 16, 2024
  1. OK I was stupid to search getSpec in surface. it's a function of a flexScrollView.
  2. also solves this problem because getSpec() returns absolute values.
  3. also found options.enabled: bool

from famous-flex.

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.