2fa2483a7fba4d52e55dc0085b545697.json 8.34 KB
{"ast":null,"code":"import addEventListener from \"rc-util/es/Dom/addEventListener\";\nexport function getTargetRect(target) {\n  return target !== window ? target.getBoundingClientRect() : {\n    top: 0,\n    bottom: window.innerHeight\n  };\n}\nexport function getFixedTop(placeholderReact, targetRect, offsetTop) {\n  if (offsetTop !== undefined && targetRect.top > placeholderReact.top - offsetTop) {\n    return offsetTop + targetRect.top;\n  }\n\n  return undefined;\n}\nexport function getFixedBottom(placeholderReact, targetRect, offsetBottom) {\n  if (offsetBottom !== undefined && targetRect.bottom < placeholderReact.bottom + offsetBottom) {\n    var targetBottomOffset = window.innerHeight - targetRect.bottom;\n    return offsetBottom + targetBottomOffset;\n  }\n\n  return undefined;\n} // ======================== Observer ========================\n\nvar TRIGGER_EVENTS = ['resize', 'scroll', 'touchstart', 'touchmove', 'touchend', 'pageshow', 'load'];\nvar observerEntities = [];\nexport function getObserverEntities() {\n  // Only used in test env. Can be removed if refactor.\n  return observerEntities;\n}\nexport function addObserveTarget(target, affix) {\n  if (!target) return;\n  var entity = observerEntities.find(function (item) {\n    return item.target === target;\n  });\n\n  if (entity) {\n    entity.affixList.push(affix);\n  } else {\n    entity = {\n      target: target,\n      affixList: [affix],\n      eventHandlers: {}\n    };\n    observerEntities.push(entity); // Add listener\n\n    TRIGGER_EVENTS.forEach(function (eventName) {\n      entity.eventHandlers[eventName] = addEventListener(target, eventName, function () {\n        entity.affixList.forEach(function (targetAffix) {\n          targetAffix.lazyUpdatePosition();\n        });\n      });\n    });\n  }\n}\nexport function removeObserveTarget(affix) {\n  var observerEntity = observerEntities.find(function (oriObserverEntity) {\n    var hasAffix = oriObserverEntity.affixList.some(function (item) {\n      return item === affix;\n    });\n\n    if (hasAffix) {\n      oriObserverEntity.affixList = oriObserverEntity.affixList.filter(function (item) {\n        return item !== affix;\n      });\n    }\n\n    return hasAffix;\n  });\n\n  if (observerEntity && observerEntity.affixList.length === 0) {\n    observerEntities = observerEntities.filter(function (item) {\n      return item !== observerEntity;\n    }); // Remove listener\n\n    TRIGGER_EVENTS.forEach(function (eventName) {\n      var handler = observerEntity.eventHandlers[eventName];\n\n      if (handler && handler.remove) {\n        handler.remove();\n      }\n    });\n  }\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/affix/utils.js"],"names":["addEventListener","getTargetRect","target","window","getBoundingClientRect","top","bottom","innerHeight","getFixedTop","placeholderReact","targetRect","offsetTop","undefined","getFixedBottom","offsetBottom","targetBottomOffset","TRIGGER_EVENTS","observerEntities","getObserverEntities","addObserveTarget","affix","entity","find","item","affixList","push","eventHandlers","forEach","eventName","targetAffix","lazyUpdatePosition","removeObserveTarget","observerEntity","oriObserverEntity","hasAffix","some","filter","length","handler","remove"],"mappings":"AAAA,OAAOA,gBAAP,MAA6B,iCAA7B;AACA,OAAO,SAASC,aAAT,CAAuBC,MAAvB,EAA+B;AACpC,SAAOA,MAAM,KAAKC,MAAX,GAAoBD,MAAM,CAACE,qBAAP,EAApB,GAAqD;AAC1DC,IAAAA,GAAG,EAAE,CADqD;AAE1DC,IAAAA,MAAM,EAAEH,MAAM,CAACI;AAF2C,GAA5D;AAID;AACD,OAAO,SAASC,WAAT,CAAqBC,gBAArB,EAAuCC,UAAvC,EAAmDC,SAAnD,EAA8D;AACnE,MAAIA,SAAS,KAAKC,SAAd,IAA2BF,UAAU,CAACL,GAAX,GAAiBI,gBAAgB,CAACJ,GAAjB,GAAuBM,SAAvE,EAAkF;AAChF,WAAOA,SAAS,GAAGD,UAAU,CAACL,GAA9B;AACD;;AAED,SAAOO,SAAP;AACD;AACD,OAAO,SAASC,cAAT,CAAwBJ,gBAAxB,EAA0CC,UAA1C,EAAsDI,YAAtD,EAAoE;AACzE,MAAIA,YAAY,KAAKF,SAAjB,IAA8BF,UAAU,CAACJ,MAAX,GAAoBG,gBAAgB,CAACH,MAAjB,GAA0BQ,YAAhF,EAA8F;AAC5F,QAAIC,kBAAkB,GAAGZ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AACD,OAAO,SAASC,mBAAT,CAA6BX,KAA7B,EAAoC;AACzC,MAAIY,cAAc,GAAGf,gBAAgB,CAACK,IAAjB,CAAsB,UAAUW,iBAAV,EAA6B;AACtE,QAAIC,QAAQ,GAAGD,iBAAiB,CAACT,SAAlB,CAA4BW,IAA5B,CAAiC,UAAUZ,IAAV,EAAgB;AAC9D,aAAOA,IAAI,KAAKH,KAAhB;AACD,KAFc,CAAf;;AAIA,QAAIc,QAAJ,EAAc;AACZD,MAAAA,iBAAiB,CAACT,SAAlB,GAA8BS,iBAAiB,CAACT,SAAlB,CAA4BY,MAA5B,CAAmC,UAAUb,IAAV,EAAgB;AAC/E,eAAOA,IAAI,KAAKH,KAAhB;AACD,OAF6B,CAA9B;AAGD;;AAED,WAAOc,QAAP;AACD,GAZoB,CAArB;;AAcA,MAAIF,cAAc,IAAIA,cAAc,CAACR,SAAf,CAAyBa,MAAzB,KAAoC,CAA1D,EAA6D;AAC3DpB,IAAAA,gBAAgB,GAAGA,gBAAgB,CAACmB,MAAjB,CAAwB,UAAUb,IAAV,EAAgB;AACzD,aAAOA,IAAI,KAAKS,cAAhB;AACD,KAFkB,CAAnB,CAD2D,CAGvD;;AAEJhB,IAAAA,cAAc,CAACW,OAAf,CAAuB,UAAUC,SAAV,EAAqB;AAC1C,UAAIU,OAAO,GAAGN,cAAc,CAACN,aAAf,CAA6BE,SAA7B,CAAd;;AAEA,UAAIU,OAAO,IAAIA,OAAO,CAACC,MAAvB,EAA+B;AAC7BD,QAAAA,OAAO,CAACC,MAAR;AACD;AACF,KAND;AAOD;AACF","sourcesContent":["import addEventListener from \"rc-util/es/Dom/addEventListener\";\nexport function getTargetRect(target) {\n  return target !== window ? target.getBoundingClientRect() : {\n    top: 0,\n    bottom: window.innerHeight\n  };\n}\nexport function getFixedTop(placeholderReact, targetRect, offsetTop) {\n  if (offsetTop !== undefined && targetRect.top > placeholderReact.top - offsetTop) {\n    return offsetTop + targetRect.top;\n  }\n\n  return undefined;\n}\nexport function getFixedBottom(placeholderReact, targetRect, offsetBottom) {\n  if (offsetBottom !== undefined && targetRect.bottom < placeholderReact.bottom + offsetBottom) {\n    var targetBottomOffset = window.innerHeight - targetRect.bottom;\n    return offsetBottom + targetBottomOffset;\n  }\n\n  return undefined;\n} // ======================== Observer ========================\n\nvar TRIGGER_EVENTS = ['resize', 'scroll', 'touchstart', 'touchmove', 'touchend', 'pageshow', 'load'];\nvar observerEntities = [];\nexport function getObserverEntities() {\n  // Only used in test env. Can be removed if refactor.\n  return observerEntities;\n}\nexport function addObserveTarget(target, affix) {\n  if (!target) return;\n  var entity = observerEntities.find(function (item) {\n    return item.target === target;\n  });\n\n  if (entity) {\n    entity.affixList.push(affix);\n  } else {\n    entity = {\n      target: target,\n      affixList: [affix],\n      eventHandlers: {}\n    };\n    observerEntities.push(entity); // Add listener\n\n    TRIGGER_EVENTS.forEach(function (eventName) {\n      entity.eventHandlers[eventName] = addEventListener(target, eventName, function () {\n        entity.affixList.forEach(function (targetAffix) {\n          targetAffix.lazyUpdatePosition();\n        });\n      });\n    });\n  }\n}\nexport function removeObserveTarget(affix) {\n  var observerEntity = observerEntities.find(function (oriObserverEntity) {\n    var hasAffix = oriObserverEntity.affixList.some(function (item) {\n      return item === affix;\n    });\n\n    if (hasAffix) {\n      oriObserverEntity.affixList = oriObserverEntity.affixList.filter(function (item) {\n        return item !== affix;\n      });\n    }\n\n    return hasAffix;\n  });\n\n  if (observerEntity && observerEntity.affixList.length === 0) {\n    observerEntities = observerEntities.filter(function (item) {\n      return item !== observerEntity;\n    }); // Remove listener\n\n    TRIGGER_EVENTS.forEach(function (eventName) {\n      var handler = observerEntity.eventHandlers[eventName];\n\n      if (handler && handler.remove) {\n        handler.remove();\n      }\n    });\n  }\n}"]},"metadata":{},"sourceType":"module"}