Example #1
0
$('#scrollToContent').on('click', function() {
  scrollToElement('#content', {
    offset: 0,
    ease: 'in-quad',
    duration: 1500
  });
});
export const updateResolved = (ori, { layoutActions, getConfigs }) => (...args) => {
  ori(...args)

  const isDeepLinkingEnabled = getConfigs().deepLinking
  if(!isDeepLinkingEnabled || isDeepLinkingEnabled === "false") {
    return
  }

  if(window.location.hash && !hasHashBeenParsed ) {
    let hash = window.location.hash.slice(1) // # is first character

    if(hash[0] === "!") {
      // Parse UI 2.x shebangs
      hash = hash.slice(1)
    }

    if(hash[0] === "/") {
      // "/pet/addPet" => "pet/addPet"
      // makes the split result cleaner
      // also handles forgotten leading slash
      hash = hash.slice(1)
    }

    let [tag, operationId] = hash.split("/")

    if(tag && operationId) {
      // Pre-expand and scroll to the operation
      layoutActions.show(["operations-tag", tag], true)
      layoutActions.show(["operations", tag, operationId], true)

      scrollTo(`#operations-${escapeDeepLinkPath(tag)}-${escapeDeepLinkPath(operationId)}`, {
        offset: SCROLL_OFFSET
      })
    } else if(tag) {
      // Pre-expand and scroll to the tag
      layoutActions.show(["operations-tag", tag], true)

      scrollTo(`#operations-tag-${escapeDeepLinkPath(tag)}`, {
        offset: SCROLL_OFFSET
      })
    }
  }

  hasHashBeenParsed = true
}
Example #3
0
  componentDidUpdate() {

    const keys = _.chain(this.refs)
      .keys()
      .filter((ff) => {
        return _.startsWith(ff, "section-");
      }).value();

    keys.sort((a, b) => {
      const aNum = parseInt(a.substr(a.indexOf("-") + 1));
      const bNum = parseInt(b.substr(b.indexOf("-") + 1));
      if (aNum < bNum) {
        return -1;
      }
      if (aNum > bNum) {
        return 1;
      }
      // a must be equal to b
      return 0;
    });
    const scrollToOptions = {
      offset: -150
    };
    if (this.state.scrollToLast) {
      const lastNode = ReactDOM.findDOMNode(this.refs[keys[keys.length - 1]]);

      ScrollToElement(lastNode, scrollToOptions);

      this.setState({
        scrollToLast: false
      });

    }

    if (this.state.scrollToOpen) {
      this.setState({
        scrollToOpen: false
      });
      const s = "section-" + this.state.openSection;
      const openNode = ReactDOM.findDOMNode(this.refs[s]);
      ScrollToElement(openNode, scrollToOptions);

    }
  }
Example #4
0
File: index.js Project: ut7/twinejs
			window.setTimeout(() => {
				scrollTo(document.querySelector(
					'#welcomeView > div:last-of-type'),
					{ duration: 400 });
			}, 10);
Example #5
0
 onClick={() => scrollToElement("#work", { duration: SCROLL_SPEED })}
Example #6
0
 onClick={() =>
   scrollToElement("#Get-In-Touch", { duration: SCROLL_SPEED })}
Example #7
0
 onClick={() =>
   scrollToElement(".container", { duration: SCROLL_SPEED })}