12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- function setHtmlFontSize() {
- var width = 750 //如果是尺寸的设计稿在这里修改
- document.documentElement.style.fontSize = (100 * innerWidth) / width + 'px'
- }
- setHtmlFontSize()
- function windowReload() {
- var isMiniScreen = innerWidth <= 768
- window.addEventListener('resize', function () {
- setHtmlFontSize()
- console.log(innerWidth)
- if (isMiniScreen) {
- if (innerWidth > 768) {
- window.location.reload()
- }
- } else {
- if (innerWidth < 768) {
- window.location.reload()
- }
- }
- })
- }
- windowReload()
- function startMenuAction() {
- $(function () {
- var isAnimated = false
- $('[data-toggle="dropdown"]').on('click', function () {
- if (isAnimated) return
- isAnimated = true
- $(this).parent('.dropdown').toggleClass('open')
- $(this)
- .siblings('.dropdown-menu')
- .slideToggle(false, function () {
- isAnimated = false
- })
- })
- $('[data-toggle="collapse"]').on('click', function () {
- if (isAnimated) return
- isAnimated = true
- var target = $(this).attr('data-target')
- var expanded = $(this).attr('aria-expanded')
- if (expanded === 'true') {
- expanded = 'false'
- } else {
- expanded = 'true'
- }
- $(this).attr('aria-expanded', expanded)
- if (expanded === 'false') {
- $(target).css('background-color', 'transparent')
- }
- $(target).slideToggle(function () {
- if (expanded === 'true') {
- $(this).css('background-color', 'rgba(0, 0, 0, 0.6)')
- }
- isAnimated = false
- })
- })
- })
- }
- startMenuAction()
|