Commit Graph

221 Commits

Author SHA1 Message Date
Mikael Sand 3cff87fd4f Fix compatibility with svgr and images
#971
2019-03-17 03:27:53 +02:00
Mikael Sand bd6ffcafe3 [js] optimize object allocations 2019-03-10 03:39:30 +02:00
Mikael Sand dc94707008 Refactor props handling in text, tspan and clippath 2019-02-27 23:23:09 +02:00
Mikael Sand aec8015255 Refactor: unroll static loop 2019-02-27 21:11:27 +02:00
Mikael Sand 0b1f53698b [android] Make SvgView.drawChildren synchronized
Fix race-condition
https://github.com/react-native-community/react-native-svg/issues/948
Refactor toDataUrl
2019-02-27 21:09:50 +02:00
Mikael Sand 131ddb6a1a Implement version of toDataURL with width and height options
https://github.com/react-native-community/react-native-svg/issues/855
2019-02-10 03:42:18 +02:00
Mikael Sand 6777211d7e Use singleQuote 2019-01-29 04:51:56 +02:00
Mikael Sand 76bc07fce9 Shrink indent_size / tabWidth 2019-01-29 03:03:05 +02:00
Mikael Sand 546f22587f Allow style arrays to affect text properties
Ensure props and styles are merged only once per render
Configure prettier
2019-01-29 02:54:22 +02:00
Mikael Sand 60988cfd06 Fix linting 2019-01-25 16:35:10 +02:00
Mikael Sand f5cdc31934 Simplify Svg element render method and pickNotNil 2019-01-25 16:14:42 +02:00
Mikael Sand 5551ff2bfa Fix #840
Implement support for patternUnits="objectBoundingBox"
 seems to work well on both platforms
Implement support for patternContentUnits="objectBoundingBox"
 Android has issues with small paths
2019-01-25 04:23:33 +02:00
Mikael Sand 76fb495920 Fix #844
Handle svg root width/height attribute strings containing px on iOS
Inherit fill/stroke attributes from Mask elements
Set default bounding box of mask to fill viewport / allow missing x, y, width, height on mask element
2019-01-24 20:27:45 +02:00
Mikael Sand b3d29c9045 Remove string conversion of svg bounds, allow style arrays more widely 2019-01-24 02:44:28 +02:00
Mikael Sand bc14b90773 Accept xlinkHref as fallback to href, Fixes #500 2019-01-23 19:04:01 +02:00
Mikael Sand eb3e67a257 Implement support for animating gradient stops, fixes #884
```jsx
import * as React from 'react';
import { View, StyleSheet, Animated } from 'react-native';
import { Svg, Defs, LinearGradient, Stop, Rect } from 'react-native-svg';

const AnimatedStop = Animated.createAnimatedComponent(Stop);

export default class App extends React.Component {
  state = {
    anim: new Animated.Value(0),
  };
  componentDidMount = () => {
    Animated.timing(this.state.anim, {
      duration: 3000,
      toValue: 1,
    }).start();
  };
  render() {
    return (
      <View style={styles.container}>
        <Svg width="100%" height="100%">
          <Defs>
            <LinearGradient id="grad" x1="0" y1="50" x2="100" y2="50">
              <Stop offset="0%" stopColor="#888" stopOpacity="1" />
              <AnimatedStop
                offset={this.state.anim}
                stopColor="#888"
                stopOpacity="0.1"
              />
              <Stop offset="100%" stopColor="#888" stopOpacity="1" />
            </LinearGradient>
          </Defs>
          <Rect
            x="10"
            y="20"
            rx="16"
            ry="16"
            width="96"
            height="32"
            fill="url(#grad)"
          />
        </Svg>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
  },
});
```
2019-01-23 17:09:35 +02:00
Mikael Sand 71bc5b8c28 [iOS] Fix Pattern element regression, fixes #906 2019-01-23 00:33:56 +02:00
Mikael Sand 13552cfc49 Refactor, rewrite iterables and for of to plain access and for loops 2019-01-22 21:54:04 +02:00
Mikael Sand eeae255fdd Inherit from Shape where refMethod is used 2019-01-22 18:22:06 +02:00
Mikael Sand 3dc6b80953 [android] Fix Use element spec conformance (x and y interpretation) 2019-01-14 15:44:00 +02:00
Mikael Sand ccb615dbca [iOS] Fix Use element spec conformance (x and y interpretation) 2019-01-14 15:03:28 +02:00
Mikael Sand ca611a4416 Lift default setNativeProps and refMethod implementation to Shape class 2019-01-09 15:41:43 +02:00
Mikael Sand 51917038c0 Add class names 2019-01-08 23:32:45 +02:00
Mikael Sand 0160ac5140 Add missing setNativeProps 2019-01-08 23:25:26 +02:00
Mikael Sand fd772cdf11 Remove redundant id and constructor from root svg element. 2019-01-08 23:15:30 +02:00
Mikael Sand c7ed29b33a Simplify id/url regex matching. Allow mask/clipPath without url prefix.
Remove redundant variables.
Unify use of newlines.
2019-01-08 22:53:03 +02:00
Mikael Sand b559e73dbc [android] Cache text groups. Refactor Svg root group structure. 2019-01-06 20:02:14 +02:00
Mikael Sand 35dca0d98f Refactor svg bounds extraction 2019-01-06 19:38:47 +02:00
Mikael Sand 63991dbb4f Organize imports. (ios) Fix numeric font size handling. 2019-01-06 17:28:42 +02:00
Mikael Sand 4a2d0f561a Remove outdated comments 2019-01-06 16:59:09 +02:00
Mikael Sand 9fa7a4045c Refactor, optimize length list extraction for minimal transformations. 2019-01-06 16:14:18 +02:00
Mikael Sand 84bd922747 Use const where possible 2019-01-06 15:08:47 +02:00
Mikael Sand de3e1f9b1e Ensure TSpan is imported if Text is imported. 2019-01-06 13:53:13 +02:00
Mikael Sand aad9c21d0d Specialize G props extraction 2019-01-06 13:48:20 +02:00
Mikael Sand e18b2512a5 Specialize G props extraction 2019-01-06 13:42:41 +02:00
Mikael Sand 0146792e9b Use setter instead of parameter injection, fix/specialize extraction 2019-01-06 13:22:13 +02:00
Mikael Sand 741509763c Refactor, simplify, improve readability, remove redundant closures. 2019-01-06 01:31:34 +02:00
Mikael Sand e8d23439a4 Refactor extractGradient, simplify RNSVGCGGradient conversion, prettier 2019-01-05 22:28:16 +02:00
Mikael Sand 07292c1ab0 Optimize startup
Compile transform parser in development instead of in run-time
Remove lodash dependency and use tailor-made replacements instead
Change pag.js from dependency to dev dependency
2019-01-05 17:43:51 +02:00
Janic Duplessis bb57f86906 Fix compat with latest RN master
The code in the Shape constructor assumes that `SvgTouchableMixin` contains only functions but [this](https://github.com/facebook/react-native/blob/master/Libraries/Components/Touchable/Touchable.js#L904) was added which breaks this assumption.

This simply makes sure whatever we assign is a function before calling `.bind`.
2018-12-16 21:55:05 +02:00
Mikael Sand 2f513504d2 [ios] Fix gesture responder, onPress/In/Out, onLayout 2018-12-08 03:04:22 +02:00
Mikael Sand 766926f758 Add support for clipRule on ClipPath element
[iOS] fix spec conformance, clipRule on non ClipPath elements must not
have any effect.
2018-10-24 22:13:41 +03:00
Mikael Sand b9debca598 Restore support for array of styles on Svg root. 2018-10-19 18:26:41 +03:00
Mikael Sand b6d17ff1df Fix merge issue 2018-10-19 18:26:02 +03:00
Mikael Sand d91e3e5755 Merge pull request #805 from janicduplessis/no-proptypes
Remove prop-types
2018-10-19 18:13:37 +03:00
Adam Sajko 2602cb951b Fix require cycle between extractText.js and TSpan.js 2018-10-16 08:35:28 +02:00
Janic Duplessis 0be0d00fc3 Remove prop-types 2018-10-14 17:15:12 -04:00
Mikael Sand a548179363 Simplify project structure 2018-10-12 19:54:07 +03:00
Mikael Sand 600c13c526 Remove internal import from react-native 2018-10-12 19:38:48 +03:00
Mikael Sand 6f256f1da1 Use const where possible, cleanup attributes, fix imports
Fix viewBox validation
2018-10-12 19:37:44 +03:00