From 0a197a41c4b6a76d15c2f390613be75d361730b0 Mon Sep 17 00:00:00 2001 From: GJS <1353990812@qq.com> Date: Wed, 21 Sep 2016 11:43:58 +0800 Subject: [PATCH] add a feature of customing item for renderPage --- .DS_Store | Bin 0 -> 6148 bytes library/Gallery.js | 13 ++++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0402f1081d28d074c17df5f635afbb13aca9514e GIT binary patch literal 6148 zcmeHKOKQVF43!!~0^NAoowJc0CP zG`b@02WICYvK@y3`~Ox465dcp+QH!WL-@h0)sA^!-wXRH76AHr{n(O<)Sr^kqS_O zu>y|0H*367_SVVES+6bdcevHu;bvGn1;N`f(AzOK f){bAiDC&x>ab6RLK&K<`bRd5QOcxpzc(ejvYIha1 literal 0 HcmV?d00001 diff --git a/library/Gallery.js b/library/Gallery.js index 3fd01ed..af59990 100644 --- a/library/Gallery.js +++ b/library/Gallery.js @@ -218,8 +218,19 @@ export default class Gallery extends Component { this.props.onPageScroll && this.props.onPageScroll(e); } + setImageRef(pageId, ref) { + this.imageRefs.set(pageId, ref); + } + + deleteImageRef(pageId) { + this.imageRefs.delete(`${pageId}`); + } + renderPage(pageData, pageId, layout) { - const { onViewTransformed, onTransformGestureReleased, ...other } = this.props; + const { onViewTransformed, onTransformGestureReleased, customItem, ...other } = this.props; + if (customItem && typeof customItem === 'function') { + return customItem(pageData, pageId, layout, this); + }; return (