@@ -517,7 +517,6 @@ exports.default = Plugin;
517
517
/* 24 */
518
518
/***/ ( function ( module , exports , __webpack_require__ ) {
519
519
520
- var disposed = false
521
520
var Component = __webpack_require__ ( 25 ) (
522
521
/* script */
523
522
__webpack_require__ ( 26 ) ,
@@ -530,25 +529,6 @@ var Component = __webpack_require__(25)(
530
529
/* moduleIdentifier (server only) */
531
530
null
532
531
)
533
- Component . options . __file = "/Users/mauricio/web/vue-scrollactive/src/scrollactive.vue"
534
- if ( Component . esModule && Object . keys ( Component . esModule ) . some ( function ( key ) { return key !== "default" && key . substr ( 0 , 2 ) !== "__" } ) ) { console . error ( "named exports are not supported in *.vue files." ) }
535
- if ( Component . options . functional ) { console . error ( "[vue-loader] scrollactive.vue: functional components are not supported with templates, they should use render functions." ) }
536
-
537
- /* hot reload */
538
- if ( false ) { ( function ( ) {
539
- var hotAPI = require ( "vue-hot-reload-api" )
540
- hotAPI . install ( require ( "vue" ) , false )
541
- if ( ! hotAPI . compatible ) return
542
- module . hot . accept ( )
543
- if ( ! module . hot . data ) {
544
- hotAPI . createRecord ( "data-v-75a6c496" , Component . options )
545
- } else {
546
- hotAPI . reload ( "data-v-75a6c496" , Component . options )
547
- }
548
- module . hot . dispose ( function ( data ) {
549
- disposed = true
550
- } )
551
- } ) ( ) }
552
532
553
533
module . exports = Component . exports
554
534
@@ -756,7 +736,8 @@ exports.default = {
756
736
data : function data ( ) {
757
737
return {
758
738
scrollactiveItems : null ,
759
- bezierEasing : __webpack_require__ ( 57 )
739
+ bezierEasing : __webpack_require__ ( 57 ) ,
740
+ lastActiveItem : null
760
741
} ;
761
742
} ,
762
743
@@ -773,6 +754,11 @@ exports.default = {
773
754
} ,
774
755
775
756
methods : {
757
+ /**
758
+ * Will be called when scrolling event is triggered to handle
759
+ * the addition of the active class in the current section item
760
+ * and fire the change event.
761
+ */
776
762
onScroll : function onScroll ( ) {
777
763
var distanceFromTop = window . scrollY ;
778
764
var currentItem = void 0 ;
@@ -807,8 +793,20 @@ exports.default = {
807
793
}
808
794
}
809
795
796
+ if ( currentItem != this . lastActiveItem ) {
797
+ // Makes sure to not fire when it's mounted
798
+ if ( this . lastActiveItem ) this . $emit ( 'itemchanged' , event , currentItem , this . lastActiveItem ) ;
799
+ this . lastActiveItem = currentItem ;
800
+ }
801
+
810
802
if ( currentItem ) currentItem . classList . add ( this . activeClass ) ;
811
803
} ,
804
+
805
+
806
+ /**
807
+ * Sets the initial list of menu items, validating if there's none
808
+ * or if its hash corresponds to a valid element ID.
809
+ */
812
810
setScrollactiveItems : function setScrollactiveItems ( ) {
813
811
var scrollactiveItems = document . querySelectorAll ( '.scrollactive-item' ) ;
814
812
@@ -845,6 +843,11 @@ exports.default = {
845
843
846
844
this . scrollactiveItems = scrollactiveItems ;
847
845
} ,
846
+
847
+
848
+ /**
849
+ * Handles the scrolling when clicking a menu item.
850
+ */
848
851
scrollToTargetElement : function scrollToTargetElement ( event ) {
849
852
event . preventDefault ( ) ;
850
853
@@ -1594,20 +1597,13 @@ module.exports = function bezier (mX1, mY1, mX2, mY2) {
1594
1597
1595
1598
/***/ } ) ,
1596
1599
/* 58 */
1597
- /***/ ( function ( module , exports , __webpack_require__ ) {
1600
+ /***/ ( function ( module , exports ) {
1598
1601
1599
1602
module . exports = { render :function ( ) { var _vm = this ; var _h = _vm . $createElement ; var _c = _vm . _self . _c || _h ;
1600
1603
return _c ( 'nav' , {
1601
1604
staticClass : "scrollactive-nav"
1602
1605
} , [ _vm . _t ( "default" ) ] , 2 )
1603
1606
} , staticRenderFns : [ ] }
1604
- module . exports . render . _withStripped = true
1605
- if ( false ) {
1606
- module . hot . accept ( )
1607
- if ( module . hot . data ) {
1608
- require ( "vue-hot-reload-api" ) . rerender ( "data-v-75a6c496" , module . exports )
1609
- }
1610
- }
1611
1607
1612
1608
/***/ } )
1613
1609
/******/ ] ) ;
0 commit comments