resize.js 734 B

123456789101112131415161718192021222324
  1. (function(doc, win) {
  2. var docEl = doc.documentElement,
  3. resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
  4. recalc = function() {
  5. var clientWidth = docEl.clientWidth;
  6. if (!clientWidth) return;
  7. if (clientWidth >= 1080) {
  8. docEl.style.fontSize = '100px';
  9. } else {
  10. docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
  11. }
  12. };
  13. if (!doc.addEventListener) return;
  14. win.addEventListener(resizeEvt, recalc, false);
  15. doc.addEventListener('DOMContentLoaded', recalc, false);
  16. var docEl = document.documentElement;
  17. var clientWidth = docEl.clientHeight;
  18. })(document, window);
  19. function toThousands(num, decimal) {
  20. let numInfo = num ? num : 0
  21. return parseFloat(numInfo).toFixed(decimal)
  22. }