Skip to content

Commit

Permalink
fix: Typo in defineDirective (Closes #35) (#36)
Browse files Browse the repository at this point in the history
* fix: typo `updated` => `update`

* Add the test page for a directive update
  • Loading branch information
sa16ot authored Mar 18, 2020
1 parent 042d761 commit fdeb078
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/vue-waypoint.js

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

2 changes: 1 addition & 1 deletion src/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const defineDirective = Vue => {
vnode._waypoint = waypoint
}
},
updated (el, binding, vnode, oldVnode) {
update (el, binding, vnode, oldVnode) {
const { active, callback, options } = binding.value

// we remove the old observer anyways
Expand Down
53 changes: 53 additions & 0 deletions test/update.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>vue-waypoint directive update test</title>
<script src="https://unpkg.com/vue"></script>
<script src="../dist/vue-waypoint.js"></script>
<style>
.wrapper {
width: 300vw;
height: 300vh;
display: flex;
justify-content: center;
align-items: center;
}
.visible {
background-color: #48e400;
}
.waypoint {
width: 400px;
height: 50px;
}
</style>
</head>
<body>
<div id="app">
<div class="wrapper" :class="{ visible }">
<button
v-waypoint="{ active, callback }"
class="waypoint"
@click="active = !active"
>
Waypoint holder (<b>click to {{ active ? 'deactivate' : 'activate' }}</b>)
</button>
</div>
</div>

<script>
var app = new Vue({
el: '#app',
data: {
active: true,
visible: false
},
methods: {
callback({ going }) {
this.visible = going == this.$waypointMap.GOING_IN
}
}
})
</script>
</body>
</html>

0 comments on commit fdeb078

Please sign in to comment.