GithubHelp home page GithubHelp logo

Comments (3)

faelsoto avatar faelsoto commented on July 21, 2024

That's an interesting approach, we might have to test that.

However there might be a couple issues with it:

  1. I'm not sure translate would clip correctly the instructions, as the calculated height would be the same.
  2. It would move the body, but not resize it. This might bring additional issues.

We initially went with a position: absolute element, growing its height and adding padding to the mainElement. It seemed hacky and not very elegant. @pateketrueke rewrote it so its height would push down the content, and we're using min-height because in some instances, if you're using flexbox, the height would not be taken into account. It was weird.

Maybe through the API we can allow the use case when you need to calculate both element's position/height? Or maybe we could try with will-change?

from pulltorefresh.js.

kazzkiq avatar kazzkiq commented on July 21, 2024

I'm not sure, but as far as I know, will-change property only works optimizing properties that already use GPU acceleration. This means that it would have little to no effect to properties such as min-height.

I think the best approach (which would probably lead to structure break and maybe should be focused for further major versions) would be to wrap the whole app body into an element, and use translate3d on both the refresh bar and this element wrapper.

Something like:

<div id="refresh-bar"></div>
<div class="body-wrapper">
  <!-- the page content -->
</div>

Then the styles would be applied as follow (according to touch-move):

<div id="refresh-bar" style="transform: translate3d(0, 35.6665px, 0)"></div>
<div class="body-wrapper" style="transform: translate3d(0, 35.6665px, 0)">>
  <!-- the page content -->
</div>

This would enable pushing the whole page content bellow, but making use of translate3d() GPU-enabled property.

from pulltorefresh.js.

faelsoto avatar faelsoto commented on July 21, 2024

The thing with modifying the markup is precisely the counter-point of this proyect: other libraries require changing the structure. And that was a no-no in our use case as it can break a lot of things: from CSS selectors to markup/CSS tricks (like the demo's sticky footer with flexbox).

Adding a to the wrapper would break a lot of thing. Even if it doesn't, moving the main element with translate would overlap with other elements that are not inside the wrapper.

The main focus on this library is making a pull to refresh feature as easy and painless as possible, that's why we went with a new element that pushes down the content, but it doesn't require the dev to rewrite the markup.

from pulltorefresh.js.

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.