Giter Site home page Giter Site logo

Comments (8)

baptistebriel avatar baptistebriel commented on May 31, 2024

Hi @skhtml,

So how things are working in the demos folder;

  • index.js
  • custom.js
  • build.js

index.js is the main entry file of the folder where I'll be importing my custom class and just initialising a new instance of the class, right away

import Custom from './custom'

const scroll = new Custom({
  opacity: document.querySelector('h1')
})

scroll.init()

custom.js will be the extended class of Smooth. In there you can add other elements to transform, apply opacity to it, etc... Just pass new elements into the options when you initialise the new class (index.js just as above) and get it back into the constructor of your custom class.

import Smooth from '../../index'

class Custom extends Smooth {
  constructor(opt) {
    super(opt)
    this.dom.opacity = opt.opacity
  }
  init() {
    super.init()
    // do something else in init of this class, like adding extra event listeners, etc..
  }
  // etc...
}

build.js is just the builded file after browserify and babel did their work.

I'll try to take some time to do another demo with the transform of the vs-section + elements inside with different speeds, will get back to you as soon as possible. :)

from smooth-scrolling.

skhtml avatar skhtml commented on May 31, 2024

Ah, now i understand, thank you! :) Browserify and babel make build.js from js files. Its like when i use sass and i compile it to css. :) Wow i like it!

About smooth scrolling vs-section + smooth parallax elements inside of this section. I understand now, when we scroll vs-section with this script, we also need to change in our parallax elements start trigger viewport , because its depends of vs-section.

Thanks for answer, its will be great if you make it, because i think this script is even better than scrollmagic, ets. because everything is smooth.

from smooth-scrolling.

baptistebriel avatar baptistebriel commented on May 31, 2024

Hi @skhtml,

Have a look at the parallax-page demo, this should be what you need!

Everything works the same as the parallax demo, but you'll find some differences such as the calculations to know if the element is in the viewport (because the parent element .vs-section has a transform applied as well). Elements inside this .vs-section have a position: relative so everything in this section can be a regular website (no fixed positions like the parallax demo).

Let me know what you think!

from smooth-scrolling.

skhtml avatar skhtml commented on May 31, 2024

I just tested it, and it works very good! Thanks , this demo is awesome! just what i need. I also test in my test project, and it works perfect as well. :))
Thanks man!

When i come back from my trip, i try add functionality like skrollr .
<div class="vs-div" data-end="0.5" data-change="x:200;y:300;opacity:1">some image</div>
Its mean from begin of viewport and until 50% (middle) of viewport this div make transform3d(200,300,0) and opacity:1

from smooth-scrolling.

baptistebriel avatar baptistebriel commented on May 31, 2024

Glad to know it worked! Feel free to re-open if you have issues!

from smooth-scrolling.

vishalp36 avatar vishalp36 commented on May 31, 2024

build.js is just the builded file after browserify and babel did their work. How did you do that? Please i am new to js things...

from smooth-scrolling.

baptistebriel avatar baptistebriel commented on May 31, 2024

Hi @vishalp36 — I used npm scripts for the build process, see package.json. It's basically just using babelify indeed. If your project needs more transforms, you could use tools like gulp or webpack.

from smooth-scrolling.

vishalp36 avatar vishalp36 commented on May 31, 2024

@baptistebriel thanks a (lot)^n

from smooth-scrolling.

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.