Git Product home page Git Product logo

floema's Introduction

floema

Useful links

https://transfonter.org/

Ajax page transition

async onChange (url) {
  await this.page.hide()

  const request = await window.fetch(url)

  if (request.status === 200) {
    const html = await request.text()
    const div = document.createElement('div')
    div.innerHTML = html

    const divContent = div.querySelector('.content')

    this.template = divContent.getAttribute('data-template')
    this.content.setAttribute('data-template', this.template)
    this.content.innerHTML = divContent.innerHTML

    this.page = this.pages[this.template]
    this.page.create()
    this.page.show()

    this.addLinkListerners()
  } else {
    console.log('Error')
  }
}

addLinkListerners () {
  const links = document.querySelectorAll('a')
  each(links, link => {
    link.onclick = event => {
      event.preventDefault()

      const { href } = link

      this.onChange(href)
    }
  })
}

Handling events

We use events lib to handle events through different classes

//Preloader.js
setTimeout(_ => {
    this.emit('completed')
  }, 1000)

//App.js
this.preloader.once('completed', this.onPreloaded)

Async Load images

Use data-src instead of src and use AsyncLoad.js which use intersectionObserver to load on scroll

Infinite draggable gallery

Basically, we position the webgl textyres images using the getBoundingClientRect() of each element and their sizes. Then, we use onTouchMove, onTouchDown & onTouchUp to calculate the position of the mouse while dragging (we had lerp to have a velocity effect) Finally, we detect when a mesh is out of the window by using his position & the window width. We then add/substract the gallery width from his position to re-position it correctly, giving the feel of an infinite scroll

floema's People

Contributors

bngya avatar

Watchers

 avatar

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.