# wp-ultimate-post-grid/4.0.1/assets/js/public/grid/hover.js

WP Ultimate Post Grid, version 4.0.1. 36 lines.

- Page: https://pluginprobe.com/plugins/wp-ultimate-post-grid/4.0.1/code/assets/js/public/grid/hover.js
- Raw: https://pluginprobe.com/plugins/wp-ultimate-post-grid/4.0.1/raw/assets/js/public/grid/hover.js
- Modified: 2020-01-24T07:47:12+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-ultimate-post-grid/4.0.1/code/assets/js/public/grid/hover.js#L10-L20`.

```javascript
export default ( elemId, args ) => {
    return {
        onHover( item, hovering ) {
            const containers = item.querySelectorAll('.wpupg-hover');

            for ( let container of containers ) {
                if ( hovering ) {
                    container.classList.add('wpupg-hovering');
                } else {
                    container.classList.remove('wpupg-hovering');
                }
            }
        },
        initHover() {
            const handler = this.onHover;

            this.elem.addEventListener( 'mouseover', function(e) {
                for ( let target = e.target; target && target != this; target = target.parentNode ) {
                    if ( target.matches( '.wpupg-item' ) ) {
                        handler( target, true );
                        break;
                    }
                }
            }, false );

            this.elem.addEventListener( 'mouseout', function(e) {
                for ( let target = e.target; target && target != this; target = target.parentNode ) {
                    if ( target.matches( '.wpupg-item' ) ) {
                        handler( target, false );
                        break;
                    }
                }
            }, false );
        },
    }
};
```
