1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

eSmooth.js and elementals 2.0 RC 2 released

Discussion in 'JavaScript' started by deathshadow, Mar 5, 2017.

  1. #1
    Just thought I'd let folks know that first, a new demo for elementals.js is up:

    and that elementals.js itself:

    Is now in Release Candidate 2. If you go to the changelog you can find a list of the new functions that were added last minute, as well as one minor revision to how it works.

    Most useful of the changes are the polyfill for performance.run, Window.requestAnimationFrame and Window.cancelAnimationFrame. These are used in the new demo IF you override the safety. By default eSmooth.js will not work in IE 10/earlier due to the lack of history.pushState so that the animation can be skip the initial "jerky" movement whilst preserving the forward/back history behavior in the browser.

    I also added simple functions to pull the current window scroll position and window scroll limits, and extended String to FINALLY have a bloody "pad" command. Uhm... I should be careful how I word that.

    console.log(String('test').pad(8, 'x')); // 'testxxxx'
    console.log(String('test').pad(-8, 'xaf')); // 'xxxxtest'
    console.log(String('test').pad(-6)); // '  test'
    console.log(String('This is a test').pad(8)); // 'This is a test'
    console.log(String('test').pad('wtf'); // throws NaN halting script execution!
    Code (markup):
    See, positive number pads the right, negative number pads the left, if you omit the character a space is used, and if the padding number is shorter than the string itself, the entire string is returned as-is. If you pass a non-number parameter, an error will be thrown (this is consistent with other String functions) and if you try to pass a string of more than one character, only the first character is used. charAt(0) is used so the value is encoding safe (in theory)

    You may also find String.strFrom useful.

    console.log(String('testfile.test.txt').strFrom('.')); // 'test.txt'
    console.log(String('testfile.test.txt').strFrom('.', true)); // 'txt'
    console.log(String('testfile.test.txt').strFrom('@'); // boolean false
    Code (markup):
    Pretty straightforward that one... first parameter is the character to match, second optional parameter if true searches from the end instead of the beginning. The match is omitted from the result.

    As always, any ideas/opinions, let's hear it. I don't WANT there to be a RC 3, but I fully expect there will be now.
    deathshadow, Mar 5, 2017 IP
  2. KewL

    KewL Well-Known Member

    Likes Received:
    Best Answers:
    Trophy Points:
    eSmooth seems pretty cool DS, I think the animation can be worked on a bit.

    I forget the correct term for it, but I like when the smooth scroll starts slow, builds up, then slows down a towards the end of it's travel.
    KewL, Mar 16, 2017 IP