PageSourceSearch

https://soho-biyori.com/wp-content/plugins/simpleblogdesign-main/addon/scroll-hint/scroll-hint.js?ver=20240601

js soho-biyori.com collected 2026-09-28 12:16:59 UTC 10,375 bytes, 299 lines download raw bytes

1/**
2 * Modules in this bundle
3 * @license
4 *
5 * scroll-hint:
6 *   license: MIT (http://opensource.org/licenses/MIT)
7 *   author: steelydylan
8 *   version: 1.2.3
9 *
10 * es6-object-assign:
11 *   license: MIT (http://opensource.org/licenses/MIT)
12 *   author: Rubén Norte <[email protected]>
13 *   maintainers: rubennorte <[email protected]>
14 *   homepage: https://github.com/rubennorte/es6-object-assign
15 *   version: 1.1.0
16 *
17 * This header is generated by licensify (https://github.com/twada/licensify)
18 */
19(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ScrollHint = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
20/**
21 * Code refactored from Mozilla Developer Network:
22 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
23 */
24
25'use strict';
26
27function assign(target, firstSource) {
28  if (target === undefined || target === null) {
29    throw new TypeError('Cannot convert first argument to object');
30  }
31
32  var to = Object(target);
33  for (var i = 1; i < arguments.length; i++) {
34    var nextSource = arguments[i];
35    if (nextSource === undefined || nextSource === null) {
36      continue;
37    }
38
39    var keysArray = Object.keys(Object(nextSource));
40    for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
41      var nextKey = keysArray[nextIndex];
42      var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
43      if (desc !== undefined && desc.enumerable) {
44        to[nextKey] = nextSource[nextKey];
45      }
46    }
47  }
48  return to;
49}
50
51function polyfill() {
52  if (!Object.assign) {
53    Object.defineProperty(Object, 'assign', {
54      enumerable: false,
55      configurable: true,
56      writable: true,
57      value: assign
58    });
59  }
60}
61
62module.exports = {
63  assign: assign,
64  polyfill: polyfill
65};
66
67},{}],2:[function(require,module,exports){
68'use strict';
69
70Object.defineProperty(exports, "__esModule", {
71  value: true
72});
73
74var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
75
76var _es6ObjectAssign = require('es6-object-assign');
77
78var _util = require('./util');
79
80function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
81
82var defaults = {
83  suggestClass: 'is-active',
84  scrollableClass: 'is-scrollable',
85  scrollableRightClass: 'is-right-scrollable',
86  scrollableLeftClass: 'is-left-scrollable',
87  scrollHintClass: 'scroll-hint',
88  scrollHintIconClass: 'scroll-hint-icon',
89  scrollHintIconAppendClass: '', // 'scroll-hint-icon-white'
90  scrollHintIconWrapClass: 'scroll-hint-icon-wrap',
91  scrollHintText: 'scroll-hint-text',
92  scrollHintBorderWidth: 10,
93  remainingTime: -1,
94  enableOverflowScrolling: true,
95  applyToParents: false,
96  suggestiveShadow: false,
97  offset: 0,
98  i18n: {
99    scrollable: 'scrollable'
100  }
101};
102
103var ScrollHint = function () {
104  function ScrollHint(ele, option) {
105    var _this = this;
106
107    _classCallCheck(this, ScrollHint);
108
109    this.opt = (0, _es6ObjectAssign.assign)({}, defaults, option);
110    this.items = [];
111    var elements = typeof ele === 'string' ? document.querySelectorAll(ele) : ele;
112    var applyToParents = this.opt.applyToParents;
113
114    [].forEach.call(elements, function (element) {
115      if (applyToParents) {
116        element = element.parentElement;
117      }
118      element.style.position = 'relative';
119      element.style.overflow = 'auto';
120      if (_this.opt.enableOverflowScrolling) {
121        if ('overflowScrolling' in element.style) {
122          element.style.overflowScrolling = 'touch';
123        } else if ('webkitOverflowScrolling' in element.style) {
124          element.style.webkitOverflowScrolling = 'touch';
125        }
126      }
127      var item = {
128        element: element,
129        scrolledIn: false,
130        interacted: false
131      };
132      document.addEventListener('scroll', function (e) {
133        if (e.target === element) {
134          item.interacted = true;
135          _this.updateItem(item);
136        }
137      }, true);
138      (0, _util.addClass)(element, _this.opt.scrollHintClass);
139      (0, _util.append)(element, '<div class="' + _this.opt.scrollHintIconWrapClass + '" data-target="scrollable-icon">\n        <span class="' + _this.opt.scrollHintIconClass + (_this.opt.scrollHintIconAppendClass ? ' ' + _this.opt.scrollHintIconAppendClass : '') + '">\n          <div class="' + _this.opt.scrollHintText + '">' + _this.opt.i18n.scrollable + '</div>\n        </span>\n      </div>');
140      _this.items.push(item);
141    });
142    window.addEventListener('scroll', function () {
143      _this.updateItems();
144    });
145    window.addEventListener('resize', function () {
146      _this.updateItems();
147    });
148    this.updateItems();
149  }
150
151  _createClass(ScrollHint, [{
152    key: 'isScrollable',
153    value: function isScrollable(item) {
154      var offset = this.opt.offset;
155      var element = item.element;
156      var offsetWidth = element.offsetWidth;
157
158      return offsetWidth + offset < element.scrollWidth;
159    }
160  }, {
161    key: 'checkScrollableDir',
162    value: function checkScrollableDir(item) {
163      var _opt = this.opt,
164          scrollHintBorderWidth = _opt.scrollHintBorderWidth,
165          scrollableRightClass = _opt.scrollableRightClass,
166          scrollableLeftClass = _opt.scrollableLeftClass;
167      var element = item.element;
168
169      var child = element.children[0];
170      var width = child.scrollWidth;
171      var parentWidth = element.offsetWidth;
172      var scrollLeft = element.scrollLeft;
173      if (parentWidth + scrollLeft < width - scrollHintBorderWidth) {
174        (0, _util.addClass)(element, scrollableRightClass);
175      } else {
176        (0, _util.removeClass)(element, scrollableRightClass);
177      }
178      if (parentWidth < width && scrollLeft > scrollHintBorderWidth) {
179        (0, _util.addClass)(element, scrollableLeftClass);
180      } else {
181        (0, _util.removeClass)(element, scrollableLeftClass);
182      }
183    }
184  }, {
185    key: 'needSuggest',
186    value: function needSuggest(item) {
187      var scrolledIn = item.scrolledIn,
188          interacted = item.interacted;
189
190      return !interacted && scrolledIn && this.isScrollable(item);
191    }
192  }, {
193    key: 'updateItems',
194    value: function updateItems() {
195      var _this2 = this;
196
197      [].forEach.call(this.items, function (item) {
198        _this2.updateItem(item);
199      });
200    }
201  }, {
202    key: 'updateStatus',
203    value: function updateStatus(item) {
204      var _this3 = this;
205
206      var element = item.element,
207          scrolledIn = item.scrolledIn;
208
209      if (scrolledIn) {
210        return;
211      }
212      if ((0, _util.getOffset)(element).top + Math.min(element.offsetHeight, window.innerHeight) / 2 < (0, _util.getScrollTop)() + window.innerHeight) {
213        item.scrolledIn = true;
214        if (this.opt.remainingTime !== -1) {
215          setTimeout(function () {
216            item.interacted = true;
217            _this3.updateItem(item);
218          }, this.opt.remainingTime);
219        }
220      }
221    }
222  }, {
223    key: 'updateItem',
224    value: function updateItem(item) {
225      var opt = this.opt;
226      var element = item.element;
227
228      var target = element.querySelector('[data-target="scrollable-icon"]');
229      this.updateStatus(item);
230      if (this.isScrollable(item)) {
231        (0, _util.addClass)(element, opt.scrollableClass);
232      } else {
233        (0, _util.removeClass)(element, opt.scrollableClass);
234      }
235      if (this.needSuggest(item)) {
236        (0, _util.addClass)(target, opt.suggestClass);
237      } else {
238        (0, _util.removeClass)(target, opt.suggestClass);
239      }
240      if (opt.suggestiveShadow) {
241        this.checkScrollableDir(item);
242      }
243    }
244  }]);
245
246  return ScrollHint;
247}();
248
249exports.default = ScrollHint;
250module.exports = exports['default'];
251
252},{"./util":3,"es6-object-assign":1}],3:[function(require,module,exports){
253'use strict';
254
255Object.defineProperty(exports, "__esModule", {
256  value: true
257});
258var append = exports.append = function append(element, string) {
259  var div = document.createElement('div');
260  div.innerHTML = string;
261  while (div.children.length > 0) {
262    element.appendChild(div.children[0]);
263  }
264};
265
266var addClass = exports.addClass = function addClass(element, className) {
267  if (element.classList) {
268    element.classList.add(className);
269  } else {
270    element.className += ' ' + className;
271  }
272};
273
274var removeClass = exports.removeClass = function removeClass(element, className) {
275  if (element.classList) {
276    element.classList.remove(className);
277  } else {
278    element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
279  }
280};
281
282var getScrollTop = exports.getScrollTop = function getScrollTop() {
283  return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
284};
285
286var getScrollLeft = exports.getScrollLeft = function getScrollLeft() {
287  return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
288};
289
290var getOffset = exports.getOffset = function getOffset(el) {
291  var rect = el.getBoundingClientRect();
292  return {
293    top: rect.top + getScrollTop(),
294    left: rect.left + getScrollLeft()
295  };
296};
297
298},{}]},{},[2])(2)
vendor: 3 bytes, line 299
299});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.