Skip to content

Commit

Permalink
Merge pull request #8674 from gehasia/sticky-docandtest-fix
Browse files Browse the repository at this point in the history
[Doc] Sticky : Add documentation about stick-to-bottom. Visual test f…
  • Loading branch information
colin-marshall committed May 4, 2016
2 parents 32264f8 + 69959b8 commit 72e10af
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 23 deletions.
56 changes: 53 additions & 3 deletions docs/pages/sticky.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ You can also use two anchors, if you please. Using `data-top-anchor="idOfSomethi

```html
<div class="columns small-6 right" data-sticky-container>
<div class="sticky" data-sticky data-top-anchor="example2" data-btm-anchor="foo:bottom">
<div class="sticky" data-sticky data-top-anchor="example2:top" data-btm-anchor="foo:bottom">
<img class="thumbnail" src="assets/img/generic/rectangle-5.jpg">
</div>
</div>
Expand All @@ -65,22 +65,72 @@ You can also use two anchors, if you please. Using `data-top-anchor="idOfSomethi

<div class="row">
<div class="columns small-12">
<div class="columns small-6" id="example2">
<div class="columns small-6">
<p id="example2">
<b>The image to the right will be sticky when it hits the top of this paragraph element.</b>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p id="foo">
<b>The image to the right will lose stickiness when it hits the bottom of this paragraph element.</b>
<br />
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>
<div class="columns small-6 right" data-sticky-container>
<div class="sticky" data-sticky data-top-anchor="example2:top" data-btm-anchor="foo:bottom">
<img class="thumbnail" src="assets/img/generic/rectangle-5.jpg">
</div>
</div>
</div>
</div>

## Stick to bottom

You can also stick to bottom.
Using `data-stick-to="bottom"`.
Here is an example using two anchors (like above) with a stick to bottom.
```html
<div class="columns small-6 right" data-sticky-container>
<div class="sticky" data-sticky data-stick-to="bottom" data-top-anchor="example3" data-btm-anchor="foo2:top">
<img class="thumbnail" src="assets/img/generic/rectangle-5.jpg">
</div>
</div>
```


<div class="row">
<div class="columns small-12">
<div class="columns small-6">
<p id="example3">
<b>The image to the right will be sticky when it hits the top of this paragraph element.</b>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p id="foo2">
<b>The image to the right will lose stickiness when it hits the top of this paragraph element.</b>
<br />
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>
<div class="columns small-6 right" data-sticky-container>
<div class="sticky" data-sticky data-top-anchor="example2:top" data-btm-anchor="foo" data-stick-to="bottom">
<div class="sticky" data-sticky data-top-anchor="example3:top" data-btm-anchor="foo2:top" data-stick-to="bottom">
<img class="thumbnail" src="assets/img/generic/rectangle-5.jpg">
</div>
</div>
Expand Down
112 changes: 92 additions & 20 deletions test/visual/sticky/anchors-with-callouts.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,55 @@
background-color: darkgrey;
}

.sticky-container {
background-color: #f00;
transition: height .5s ease;
.container {
background-color: rgba(255,0,0,0.7);

}

.foo {
height: 30rem;
color: white;
}

.megafoo {
height:50rem;
color: white;
}

.bar {
color: white;
}

.foo h1 {
display: inline-block;
float: right;
}

.foo:nth-child(odd) {
.foo:nth-child(odd), .bar:nth-child(odd), .megafoo:nth-child(odd) {
background-color: lightgreen;
}

.foo:nth-child(even) {
.foo:nth-child(even), .bar:nth-child(even), .megafoo:nth-child(even) {
background-color: lightblue;
}

</style>

</head>
<body>

<div class="row">

<div class="small-12 medium-2 columns">
<div class="container" data-sticky-container>
<div class="callout sticky" data-sticky data-margin-top="0" data-anchor="foo1">
<h5>Test 1</h5>
<p>I should stick to the top and bottom of #foo1. I'm not a child of any #foo's.</p>
<a href="http://foundation.zurb.com/sites/docs/stick.html" class="small button">Go to Sticky Docs</a>
<a href="http://foundation.zurb.com/sites/docs/stick.html" class="small button">Go to Sticky Docs</a>
</div>
</div>
</div>

<div class="small-12 medium-7 columns">
<div id="foo1" class="foo">
<h1>#foo1</h1>
Expand All @@ -60,7 +69,7 @@ <h1>#foo2</h1>
<div class="callout sticky" data-sticky data-margin-top="0" data-anchor="foo2">
<h5>Test 2</h5>
<p>I should stick to the top and bottom of #foo2.<br/>I'm also a child of #foo2</p>
<a href="http://foundation.zurb.com/sites/docs/stick.html" class="small button">Go to Sticky Docs</a>
<a href="http://foundation.zurb.com/sites/docs/stick.html" class="small button">Go to Sticky Docs</a>
</div>
</div>
</div>
Expand All @@ -72,9 +81,9 @@ <h1>#foo3</h1>
<h1>#foo4</h1>
<div class="container" data-sticky-container>
<div class="callout sticky" data-sticky data-margin-top="0" data-top-anchor="foo4" data-btm-anchor="foo6">
<h5>Test 4</h5>
<p>I should stick to the top of #foo4 and the bottom of #foo5.<br/>I'm a child of #foo4</p>
<a href="http://foundation.zurb.com/sites/docs/stick.html" class="small button">Go to Sticky Docs</a>
<h5>Test 3</h5>
<p>I should stick to the top of #foo4 and the top of #foo6.<br/>I'm a child of #foo4</p>
<a href="http://foundation.zurb.com/sites/docs/stick.html" class="small button">Go to Sticky Docs</a>
</div>
</div>
</div>
Expand All @@ -87,10 +96,10 @@ <h1>#foo6</h1>
<div id="foo7" class="foo">
<h1>#foo7</h1>
<div class="container" data-sticky-container>
<div class="callout sticky" data-sticky data-margin-top="0" data-top-anchor="foo6" data-btm-anchor="foo8">
<h5>Test 5</h5>
<p>I should stick to the top of #foo6 and the bottom of #foo7, but I don't go to the top of #foo6 because I'm a child of #foo7. Is this normal?</p>
<a href="http://foundation.zurb.com/sites/docs/stick.html" class="small button">Go to Sticky Docs</a>
<div class="callout sticky" data-sticky data-margin-top="0" data-top-anchor="foo6" data-btm-anchor="foo8:bottom">
<h5>Test 4</h5>
<p>I should stick to the top of #foo6 and the bottom of #foo8. I'm a child of #foo7.</p>
<a href="http://foundation.zurb.com/sites/docs/stick.html" class="small button">Go to Sticky Docs</a>
</div>
</div>
</div>
Expand All @@ -100,17 +109,80 @@ <h1>#foo8</h1>
<div id="foo9" class="foo">
<h1>#foo9</h1>
</div>
<div id="foo8" class="foo">
<div id="foo10" class="foo">
<h1>#foo10</h1>
<div class="container" data-sticky-container>
<div class="callout sticky" data-sticky data-margin-top="0" data-stick-to="bottom" data-top-anchor="foo10" data-btm-anchor="foo11:bottom">
<h5>Test 5</h5>
<p>I should stick to the top of #foo10 and the bottom of #foo11. I should be stick to the window bottom with a bottom margin of 1em (default bottom margin).</p>
<a href="http://foundation.zurb.com/sites/docs/stick.html" class="small button">Go to Sticky Docs</a>
</div>
</div>
</div>
<div id="foo11" class="foo">
<h1>#foo11</h1>
</div>
<div id="bar1" class="bar">
<h1>#bar1</h1>
<div class="container" data-sticky-container>
<div class="callout sticky" data-sticky data-margin-top="0" data-top-anchor="bar2" data-btm-anchor="bar3:bottom">
<h5>Test 6</h5>
<p>I should stick to the top of #bar2 and the bottom of #bar3.</p>
<p>Bar containers does not have fixed height, but i should be anchored correctly.</p>
<a href="http://foundation.zurb.com/sites/docs/stick.html" class="small button">Go to Sticky Docs</a>
</div>
</div>
<p>Lorem Ipsum</p>
</div>
<div id="bar2" class="bar">
<h1>#bar2</h1>
<p>Lorem</p>
</div>
<div id="bar3" class="bar">
<h1>#bar3</h1>
<p>Lorem</p>
<p>Ipsum</p>
<p>Dolor</p>
</div>
<div id="bar4" class="bar">
<h1>#bar4</h1>
<p>Lorem</p>
<p>Ipsum</p>
</div>
<div id="foo13" class="megafoo">
<h1>#foo13</h1>
<p>I'm big to force scroolbar</p>
</div>
<div id="foo12" class="foo">
<h1>#foo12</h1>
<div class="container" data-sticky-container>
<div class="callout sticky" data-sticky data-margin-top="0" data-top-anchor="foo12">
<h5>Test 7</h5>
<p>I should stick to the top of #foo12. I should be stick until window end because only data-top-anchor is set.</p>
<a href="http://foundation.zurb.com/sites/docs/stick.html" class="small button">Go to Sticky Docs</a>
</div>
</div>
</div>
<div id="foo13" class="foo">
<h1>#foo13</h1>
</div>
<div id="foo14" class="foo">
<h1>#foo14</h1>
</div>
<div id="foo15" class="megafoo">
<h1>#foo15</h1>
<p>I'm big to force scroolbar</p>
</div>


</div>

<div class="small-12 medium-3 columns">
<div class="container" data-sticky-container>
<div class="callout sticky" data-sticky data-margin-top="0" data-anchor="foo3">
<h5>Test 3</h5>
<h5>Test 8</h5>
<p>I should stick to the top and bottom of #foo3.<br/>I'm not the child of any of you #foo's.<br/>When I'm not stuck I jump to the top because I'm not a child of the top anchor, is this my normal behavior?</p>
<a href="http://foundation.zurb.com/sites/docs/stick.html" class="small button">Go to Sticky Docs</a>
<a href="http://foundation.zurb.com/sites/docs/stick.html" class="small button">Go to Sticky Docs</a>
</div>
</div>
</div>
Expand All @@ -122,4 +194,4 @@ <h5>Test 3</h5>
$(document).foundation();
</script>
</body>
</html>
</html>

0 comments on commit 72e10af

Please sign in to comment.