This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main exposing (main) | |
import Html exposing (Html, br, div, input, text) | |
import Html.Attributes exposing (defaultValue, type_, value) | |
import Html.Events exposing (onInput) | |
-- Elm 0.18 implementation | |
-- Example can be found on https://ellie-app.com/sbw95cJgz2a1 | |
-- MODEL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const scrollToElement = (id) => { | |
let duration = 1000; | |
let element = document.getElementById(id); | |
if (!element) | |
return; | |
let targetPosition = element.offsetTop; | |
let startPosition = window.pageYOffset; | |
let distance = targetPosition - startPosition; | |
let startTime = null; |