Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add site to examples of live sites with Smoothstate #308

Open
wants to merge 84 commits into
base: update_readme
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
57d70b2
Merge pull request #179 from miguel-perez/update_readme
Jun 12, 2015
9819115
Correct typos in README.md
Weefa Jun 12, 2015
fd6b4e4
Merge pull request #180 from Weefa/master
Jun 12, 2015
68d07aa
Fix some types in the readme.
erbridge Jun 12, 2015
5f48fe6
Update the readme.
erbridge Jun 13, 2015
2323ddb
Fix an internal link in the readme.
erbridge Jun 13, 2015
5028fc4
Merge pull request #181 from erbridge/patch-1
Jun 13, 2015
80eff50
Update the readme.
erbridge Jun 13, 2015
0f2ed30
Merge pull request #182 from erbridge/patch-1
Jun 13, 2015
4336264
Update README.md
Jun 19, 2015
92ee37b
typo in README.md
Jul 20, 2015
15a10ff
Merge pull request #196 from shrpne/master
Jul 27, 2015
8dcd740
Updated the bindEventHandlers function to handle falsey options.ancho…
DigitalMachinist Jul 27, 2015
2da1ad6
Merge pull request #197 from DigitalMachinist/master
Jul 28, 2015
4f82ff4
Added bower_components and all sublime project/workspace files to the…
DigitalMachinist Jul 31, 2015
6f40d22
Patch for Issue #198 on github (https://github.com/miguel-perez/smoot…
DigitalMachinist Jul 31, 2015
4dae081
Generalized rate limiting to all anchor clicks and form submits becau…
DigitalMachinist Jul 31, 2015
470f74f
Updated README.md to include options.repeatDelay.
DigitalMachinist Jul 31, 2015
8d12160
NOTE: I was forced to bump the maximum cyclomatic complexity to 7 in …
DigitalMachinist Jul 31, 2015
fd59084
Minor rewording in README.md.
DigitalMachinist Jul 31, 2015
cfdbe16
Patch for issue #193.
DigitalMachinist Jul 31, 2015
f6f6557
Merge pull request #199 from DigitalMachinist/master
Aug 4, 2015
6930e58
fix repositionWindow
Aug 6, 2015
c41bc1c
Merge pull request #201 from shrpne/shrpne
Aug 6, 2015
52c45d1
Potential fix for ongoing issue #189, modified from attempted solutio…
DigitalMachinist Aug 7, 2015
f78a8e9
Merge branch 'master' of https://github.com/miguel-perez/smoothState.js
DigitalMachinist Aug 7, 2015
731c764
added the unedited ajax reponse to the cache object
pudgereyem Aug 13, 2015
1434cce
Potential fix for #194 based on suggestion from @neon64. When set to …
DigitalMachinist Aug 14, 2015
a5b0d4c
Merge pull request #207 from DigitalMachinist/master
Aug 14, 2015
654f1b2
Merge branch 'master' of https://github.com/miguel-perez/smoothState.js
DigitalMachinist Aug 14, 2015
64c93db
Merge pull request #209 from DigitalMachinist/master
Aug 16, 2015
c732168
New option: hrefRegex
igoratsok Aug 19, 2015
7b9a9f2
New option: hrefRegex
igoratsok Aug 19, 2015
01be2b3
A correction.
igoratsok Aug 19, 2015
4aa4f28
Adding corrections in testUtility
igoratsok Aug 19, 2015
cdf4cfd
Add option do disable default scrollTop behavior
Sep 28, 2015
6008d15
Merge pull request #211 from slumki/master
Sep 28, 2015
5240fc5
Merge pull request #206 from pudgereyem/master
Sep 28, 2015
268706f
Add option do disable default scrollTop behavior
Oct 1, 2015
6f06611
Merge pull request #220 from shrpne/prScroll2
Oct 1, 2015
a66e461
Fix formatting.
Oct 23, 2015
f92c3b9
Add gulp serve task
Oct 26, 2015
66c2f86
Add demo: different transition per clicked anchor
bfncs Dec 1, 2015
13fbf63
Merge pull request #233 from bfncs/demo-anchor-transitions
Dec 1, 2015
4026db0
Correct a URL in demos/index.html
cnkevinlee Dec 7, 2015
a2afd25
Merge pull request #234 from cnkevinlee/master
Dec 7, 2015
39ad0e9
fixed $.ajax deferred syntax
jonathanzong Dec 21, 2015
9ad8885
Added an option to blacklist elements for prefetching (e.g. for logou…
timoschwarzer Dec 27, 2015
2d5fb6a
Added an option to blacklist elements for prefetching (e.g. for logou…
timoschwarzer Dec 27, 2015
9400e16
Merge remote-tracking branch 'origin/master'
timoschwarzer Dec 27, 2015
48a99d1
Merge pull request #236 from timoschwarzer/master
Dec 29, 2015
227dfaf
Merge pull request #235 from jonathanzong/master
Dec 29, 2015
2ce6150
Added 'alterChangeState' handler
mcaskill Feb 4, 2016
0330e73
Merge pull request #248 from mcaskill/alter-history
Feb 7, 2016
f1583c5
Updated README about 'alterChangeState'
mcaskill Feb 8, 2016
0a7a6fd
Making it work better with AMD tools
mcaskill Feb 10, 2016
e4589a3
Merge pull request #252 from mcaskill/modularized
Feb 12, 2016
caa2b2c
Merge pull request #250 from mcaskill/alter-history
Feb 12, 2016
fb4c0cb
Update README.md
Feb 15, 2016
c37a944
added new demo to demo folder
danijelgrabez Feb 29, 2016
47a9452
Merge pull request #256 from danijelgrabez/new-demo
Feb 29, 2016
02845f0
Various Fixes + Update NPM + Cleanup Demos
mcaskill Mar 16, 2016
a4f1b18
Fix popstate event event variable
jasonheecs Mar 22, 2016
ce59bf6
Added bindPrefetchHandlers method
Apr 5, 2016
a2157ae
Cleaned up formatting
Apr 5, 2016
f3ba55e
Fixes #265
mcaskill Apr 18, 2016
ab789ab
Merge pull request #261 from mcaskill/mcaskill-patch-261
Apr 21, 2016
6207b3c
Merge pull request #264 from sean-kennedy/bindprefetch
Apr 21, 2016
b7a53e1
Merge pull request #263 from jasonheecs/patch-1
Apr 21, 2016
3f1bfcf
Minified JS
mcaskill Apr 22, 2016
9d2a151
Merge pull request #269 from mcaskill/mcaskill-patch-268
Apr 26, 2016
b3c9fdf
Add demo image
Apr 27, 2016
5f3b672
Update README.md
Apr 27, 2016
836d59c
Update README.md
Apr 27, 2016
05a9dfa
Update README.md
Apr 27, 2016
5e6fbb3
Add gif of demo
Apr 27, 2016
66db1e7
Update README.md
Apr 27, 2016
b5eedc2
Update README.md
Apr 27, 2016
0f12578
Update README.md
Apr 29, 2016
bc878e0
Added support for redirected requests.
mcaskill Apr 18, 2016
938ca0e
Merge pull request #267 from mcaskill/mcaskill-patch-267
Jul 22, 2016
a22f5b6
Update README.md
Oct 6, 2016
cd8e53a
docs: Fix simple typo, thid -> this
timgates42 Sep 22, 2020
b01ce99
Merge pull request #380 from timgates42/bugfix_typo_this
miguel-perez Dec 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
node_modules
bower_components
.DS_Store
*sublime-*
4 changes: 2 additions & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"undef": true,
"unused": "vars",
"strict": true,
"maxparams": 4,
"maxparams": 6,
"maxdepth": 4,
"maxstatements": 15,
"maxcomplexity": 6
"maxcomplexity": 7
}
364 changes: 225 additions & 139 deletions README.md

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions demos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Demos with smoothState.js

If you don't have a local webserver, you can [view the demos here](https://rawgit.com/miguel-perez/smoothState.js/master/demos/index.html).

## Install

To install the demos, copy all files to the root of your local webserver.

If you have python installed, you can simply run `python -m SimpleHTTPServer` after you `cd` into the demos directory.

Alternatively, you can use the built-in static webserver.

1. Install Node.js dependencies: `npm install http-server`
2. Start webserver `npm http-server ./ -p 8080`
3. You can now access the demo site under [`http://localhost:8080`](http://localhost:8080)
9 changes: 9 additions & 0 deletions demos/anchor-transitions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Demo: Different page transitions based on clicked anchor with smoothState.js

This demo shows how to switch transitions based on initiating link with [smoothState.js](https://github.com/miguel-perez/smoothState.js). This solution has been inspired by [@pudgereyem's comment](https://github.com/miguel-perez/smoothState.js/issues/143#issuecomment-84967896) on [smoothState.js #143](https://github.com/miguel-perez/smoothState.js/issues/143).

You can [view the demo here](https://rawgit.com/miguel-perez/smoothState.js/master/demos/anchor-transitions/index.html).

The demo implements a crude idea of viewports that are horizontally aligned to determine the needed animation: every anchor has a numeric `data-target` paramter that represents the needed viewport while every scene element provides a numeric `data-viewport` parameter that reprents the current viewport. If the viewport requested for the clicked target is larger then the current viewport, the scene element is moved to the left, else to the right.

The logic to determine the wanted animation is implemented in the `onBefore` callback, the animations themselves are defined as pure CSS animations. Please feel free to take this as a starting point to implement you own animation logic.
202 changes: 202 additions & 0 deletions demos/anchor-transitions/assets/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
#main {
max-width: 720px;
margin: 0 auto;
padding: 2em 1em;
}

.nav {
margin: 0;
padding: 0;
list-style: none;
}

.nav:before {
content: 'Navigation: ';
}

.nav li {
display: inline;
margin: 0 .4em;
}

@-webkit-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}

@keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}

@-webkit-keyframes fadeOut {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}

@keyframes fadeOut {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}

@-webkit-keyframes moveInFromLeft {
0% {
opacity: 0;
-webkit-transform: translateX(-100px);
transform: translateX(-100px);
}
100% {
opacity: 1;
-webkit-transform: translateX(0);
transform: translateX(0);
}
}

@keyframes moveInFromLeft {
0% {
opacity: 0;
-webkit-transform: translateX(-100px);
transform: translateX(-100px);
}
100% {
opacity: 1;
-webkit-transform: translateX(0);
transform: translateX(0);
}
}

@-webkit-keyframes moveOutToLeft {
0% {
opacity: 1;
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
opacity: 0;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
}
}

@keyframes moveOutToLeft {
0% {
opacity: 1;
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
opacity: 0;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
}
}

@-webkit-keyframes moveInFromRight {
0% {
opacity: 0;
-webkit-transform: translateX(100px);
transform: translateX(100px);
}
100% {
opacity: 1;
-webkit-transform: translateX(0);
transform: translateX(0);
}
}

@keyframes moveInFromRight {
0% {
opacity: 0;
-webkit-transform: translateX(100px);
transform: translateX(100px);
}
100% {
opacity: 1;
-webkit-transform: translateX(0);
transform: translateX(0);
}
}

@-webkit-keyframes moveOutToRight {
0% {
opacity: 1;
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
opacity: 0;
-webkit-transform: translateX(50%);
transform: translateX(50%);
}
}

@keyframes moveOutToRight {
0% {
opacity: 1;
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
opacity: 0;
-webkit-transform: translateX(50%);
transform: translateX(50%);
}
}

.sceneElement {
-webkit-animation-duration: .4s;
animation-duration: .4s;
transition-timing-function: ease-in;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}

.is-exiting .sceneElement {
transition-timing-function: ease-out;
}

#main[data-transition=fade] .sceneElement {
-webkit-animation-name: fadeIn;
animation-name: fadeIn;
}

#main[data-transition=fade].is-exiting .sceneElement {
-webkit-animation-name: fadeOut;
animation-name: fadeOut;
}

#main[data-transition=moveleft] .sceneElement {
-webkit-animation-name: moveInFromLeft;
animation-name: moveInFromLeft;
}

#main[data-transition=moveleft].is-exiting .sceneElement {
-webkit-animation-name: moveOutToRight;
animation-name: moveOutToRight;
}

#main[data-transition=moveright] .sceneElement {
-webkit-animation-name: moveInFromRight;
animation-name: moveInFromRight;
}

#main[data-transition=moveright].is-exiting .sceneElement {
-webkit-animation-name: moveOutToLeft;
animation-name: moveOutToLeft;
}
9 changes: 9 additions & 0 deletions demos/anchor-transitions/assets/js/jquery.smoothState.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions demos/anchor-transitions/assets/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
(function ($) {

'use strict';

$(document).ready(function () {

// Init here.
var $body = $('body'),
$main = $('#main'),
$site = $('html, body'),
transition = 'fade',
smoothState;

smoothState = $main.smoothState({
onBefore: function($anchor, $container) {
var current = $('[data-viewport]').first().data('viewport'),
target = $anchor.data('target');
current = current ? current : 0;
target = target ? target : 0;
if (current === target) {
transition = 'fade';
} else if (current < target) {
transition = 'moveright';
} else {
transition = 'moveleft';
}
},
onStart: {
duration: 400,
render: function (url, $container) {
$main.attr('data-transition', transition);
$main.addClass('is-exiting');
$site.animate({scrollTop: 0});
}
},
onReady: {
duration: 0,
render: function ($container, $newContent) {
$container.html($newContent);
$container.removeClass('is-exiting');
}
},
}).data('smoothState');

});

}(jQuery));
42 changes: 42 additions & 0 deletions demos/anchor-transitions/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Home</title>

<!-- Styles -->
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<div id="main">
<ul class="nav">
<li><a href="page-left.html" data-target="-1">Left</a></li>
<li><a href="index.html" data-target="0">Home</a></li>
<li><a href="page-right.html" data-target="1">Right</a></li>
</ul>
<div class="sceneElement" data-viewport="0">
<h1>Home page</h1>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,
consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no
sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing
elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est
Lorem ipsum dolor sit amet.</p>
<p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu
feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril
delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing
elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
</div>
</div>

<!-- Scripts -->
<script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
<script src="assets/js/jquery.smoothState.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>
40 changes: 40 additions & 0 deletions demos/anchor-transitions/page-left.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>First</title>

<!-- Styles -->
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<div id="main">
<ul class="nav">
<li><a href="page-left.html" data-target="-1">Left</a></li>
<li><a href="index.html" data-target="0">Home</a></li>
<li><a href="page-right.html" data-target="1">Right</a></li>
</ul>
<div class="sceneElement" data-viewport="-1">
<h1>Left page</h1>
<p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu
feugiat nulla facilisis.</p>
<p>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus
est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et
justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores
duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna
no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit
amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
erat.</p>
</div>
</div>

<!-- Scripts -->
<script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
<script src="assets/js/jquery.smoothState.min.js"></script>
<script src="main.js"></script>
</body>
</html>
Loading