-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ONEUP-7762: Fix resize behavior (#38)
* ONEUP-7762: Add IntelliJ files to .gitignore * ONEUP-7762: Add development server * ONEUP-7762: Clean up playground page * ONEUP-7762: Only re-calculate on resize event when page size was changed * ONEUP-7762: Fix resizing behavior and simplify code * ONEUP-7762: Use better variable name * ONEUP-7762: Migrate from CircleCI to GitHub Actions * ONEUP-7762: Fix linting issues * ONEUP-7762: Change organization name * Release 1.1.1
- Loading branch information
Showing
10 changed files
with
400 additions
and
119 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Sticky Observer | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 10.x | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Lint | ||
run: yarn lint | ||
|
||
- name: Test | ||
run: yarn test | ||
|
||
- name: Build | ||
run: yarn build |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,78 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Sticky-Observer Playground</title> | ||
<script src="../dist/sticky-observer.js"></script> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
<script src="../dist/sticky-observer.js"></script> | ||
|
||
<style> | ||
.sticky-element { | ||
color: red; | ||
} | ||
|
||
.sticky-element--is-sticky { | ||
position: fixed; | ||
color: green; | ||
} | ||
|
||
</style> | ||
</head> | ||
|
||
<body> | ||
|
||
<div class="container" style="height: 5000px;"> | ||
<div class="sticky-element" data-sticky-class="sticky-element--is-sticky">example</div> | ||
</div> | ||
|
||
|
||
<script> | ||
var stickyContainer = document.querySelector('.container'); | ||
var stickyElement = document.querySelector('.sticky-element'); | ||
var stickyObserver = new sticky.StickyObserver([stickyElement], stickyContainer); | ||
|
||
stickyObserver.init(); | ||
|
||
stickyObserver.onStateChange(function (event) { | ||
switch (event.nextState) { | ||
case sticky.StickyState.STICKY: | ||
console.log('STICKY'); | ||
event.element.sticky.addStickyClass(); | ||
break; | ||
case sticky.StickyState.NORMAL: | ||
console.log('NORMAL'); | ||
event.element.sticky.removeStickyClass(); | ||
break; | ||
default: | ||
// ignore | ||
break; | ||
<style> | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
border: 0; | ||
font-family: sans-serif; | ||
font-size: 5rem; | ||
} | ||
}); | ||
|
||
stickyObserver.observe(); | ||
.sticky-element { | ||
color: red; | ||
} | ||
|
||
.sticky-element--is-sticky { | ||
position: fixed; | ||
top: 0; | ||
color: white; | ||
} | ||
|
||
.sticky-element__placeholder { | ||
height: 500px !important; | ||
background: red; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<header style="height: 100px; background: lightblue">Header</header> | ||
<div class="container" style="height: 500px;"> | ||
<div | ||
class="sticky-element" | ||
data-sticky-class="sticky-element--is-sticky" | ||
data-sticky-placeholder-class="sticky-element__placeholder" | ||
> | ||
Element | ||
</div> | ||
</div> | ||
<footer style="height: 1000px;background: lightblue">Footer</footer> | ||
|
||
<script> | ||
var stickyContainer = document.querySelector('.container'); | ||
var stickyElement = document.querySelector('.sticky-element'); | ||
var stickyObserver = new sticky.StickyObserver([stickyElement], stickyContainer); | ||
|
||
</script> | ||
stickyObserver.init(); | ||
|
||
</body> | ||
stickyObserver.onStateChange(function(event) { | ||
switch (event.nextState) { | ||
case sticky.StickyState.STICKY: | ||
event.element.sticky.addPlaceholder(); | ||
event.element.sticky.addStickyClass(); | ||
break; | ||
case sticky.StickyState.NORMAL: | ||
event.element.sticky.removePlaceholder(); | ||
event.element.sticky.removeStickyClass(); | ||
break; | ||
case sticky.StickyState.STICKY_END_OF_CONTAINER: | ||
event.element.sticky.removePlaceholder(); | ||
event.element.sticky.removeStickyClass(); | ||
break; | ||
default: | ||
// ignore | ||
break; | ||
} | ||
}); | ||
|
||
stickyObserver.observe(); | ||
</script> | ||
</body> | ||
</html> |
This file contains 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
This file contains 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
Oops, something went wrong.