Esempio n. 1
0
 onLoad = (event: Object) => {
   const { src, onLoad } = this.props
   const { width, height } = Image.resolveAssetSource(typeof src === 'string' && /^(https?:)?\/\//.test(src) ? { uri: src } : src)
   onLoad && onLoad({
     detail: { width, height }
   })
 }
Esempio n. 2
0
    render() {
        const { props } = this;
        const { preserveAspectRatio, x, y, width, height, href } = props;
        const modes = preserveAspectRatio.trim().split(spacesRegExp);
        const meetOrSlice = meetOrSliceTypes[modes[1]] || 0;
        const align = alignEnum[modes[0]] || "xMidYMid";

        return (
            <RNSVGImage
                ref={ele => {
                    this.root = ele;
                }}
                {...extractProps({ ...props, x: null, y: null }, this)}
                x={x}
                y={y}
                width={width}
                height={height}
                meetOrSlice={meetOrSlice}
                align={align}
                src={Image.resolveAssetSource(href)}
            />
        );
    }
Esempio n. 3
0
 it('type warn of loading', () => {
   const wrapper = shallow(<Button type="warn" loading />)
   const opaqueTypeRes = wrapper.find(Image).at(0).prop('source')
   expect(opaqueTypeRes).toBe(1)
   expect(Image.resolveAssetSource(opaqueTypeRes).uri).toMatch(/file:\/\//)
 })