Skip to content

Commit

Permalink
Merge branch 'master' into android-feature-dev-tools-exception
Browse files Browse the repository at this point in the history
* master:
  [WEEX-138][android]WXParallax wat not reseted to right position, when scrollToElement with animated:false option. dx dy is zero when recycleview use scrollToPosition close apache#906
  [WEEX-142][android] PullToRefresh Loading Support Scroll Back when touch not release close apache#905
  [WEEX-140][android]layout animation supported more property close apache#904
  - [jsfm] remove directive filter in attributes
  • Loading branch information
atomtong committed Nov 24, 2017
2 parents 2f2cabc + 5b1ad1a commit 4b555f4
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.animation.Animation;
Expand All @@ -41,6 +43,9 @@
import com.taobao.weex.ui.component.WXComponent;
import com.taobao.weex.ui.component.WXDiv;
import com.taobao.weex.ui.component.WXVContainer;
import com.taobao.weex.ui.component.list.BasicListComponent;
import com.taobao.weex.ui.component.list.template.WXRecyclerTemplateList;
import com.taobao.weex.ui.view.listview.WXRecyclerView;
import com.taobao.weex.utils.WXLogUtils;
import com.taobao.weex.utils.WXResourceUtils;

Expand All @@ -62,6 +67,7 @@ public class WXParallax extends WXDiv implements OnWXScrollListener, ICheckBindi
ArrayList<TransformCreator> mTransformPropArrayList = new ArrayList<>();
BackgroundColorCreator mBackgroundColor;
String mBindingRef = "";
WXComponent mBindingComponent;

private int mBackGroundColor = 0;
private float mOffsetY = 0;
Expand Down Expand Up @@ -150,8 +156,22 @@ public boolean isNeedScroller(String ref, Object option) {

@Override
public void onScrolled(View view, int dx, int dy) {

mOffsetY = mOffsetY + dy;
if(ViewCompat.isInLayout(view)){
if(mBindingComponent == null && mBindingRef != null){
mBindingComponent = findComponent(mBindingRef);
}
if(mBindingComponent instanceof BasicListComponent
&& view instanceof RecyclerView){
BasicListComponent listComponent = (BasicListComponent) mBindingComponent;
mOffsetY = Math.abs(listComponent.calcContentOffset((RecyclerView) view));
}else if(mBindingComponent instanceof WXRecyclerTemplateList
&& view instanceof RecyclerView){
WXRecyclerTemplateList listComponent = (WXRecyclerTemplateList) mBindingComponent;
mOffsetY = Math.abs(listComponent.calcContentOffset((RecyclerView) view));
}
}else{
mOffsetY = mOffsetY + dy;
}

AnimationSet animationSet = new AnimationSet(true);
boolean hasAnimation = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ public class WXTransition {
LAYOUT_PROPERTIES.add(Constants.Name.MARGIN_BOTTOM);
LAYOUT_PROPERTIES.add(Constants.Name.MARGIN_LEFT);
LAYOUT_PROPERTIES.add(Constants.Name.MARGIN_RIGHT);
LAYOUT_PROPERTIES.add(Constants.Name.LEFT);
LAYOUT_PROPERTIES.add(Constants.Name.RIGHT);
LAYOUT_PROPERTIES.add(Constants.Name.TOP);
LAYOUT_PROPERTIES.add(Constants.Name.BOTTOM);
LAYOUT_PROPERTIES.add(Constants.Name.PADDING_LEFT);
LAYOUT_PROPERTIES.add(Constants.Name.PADDING_RIGHT);
LAYOUT_PROPERTIES.add(Constants.Name.PADDING_TOP);
LAYOUT_PROPERTIES.add(Constants.Name.PADDING_BOTTOM);
}

/**
Expand Down Expand Up @@ -396,12 +404,12 @@ private PropertyValuesHolder createLayoutPropertyValueHolder(String property, Ob
switch (property){
case Constants.Name.WIDTH:{
holder = PropertyValuesHolder.ofFloat(Constants.Name.WIDTH, domObject.getLayoutWidth(),
WXViewUtils.getRealPxByWidth(WXUtils.getFloat(value), domObject.getViewPortWidth()));
WXViewUtils.getRealPxByWidth(WXUtils.getFloat(value, 0.0f), domObject.getViewPortWidth()));
}
break;
case Constants.Name.HEIGHT:{
holder = PropertyValuesHolder.ofFloat(Constants.Name.HEIGHT, domObject.getLayoutHeight(),
WXViewUtils.getRealPxByWidth(WXUtils.getFloat(value), domObject.getViewPortWidth()));
WXViewUtils.getRealPxByWidth(WXUtils.getFloat(value, 0.0f), domObject.getViewPortWidth()));
}
break;
case Constants.Name.MARGIN_TOP:{
Expand All @@ -424,6 +432,46 @@ private PropertyValuesHolder createLayoutPropertyValueHolder(String property, Ob
WXViewUtils.getRealPxByWidth(WXUtils.getFloatByViewport(value, domObject.getViewPortWidth()), domObject.getViewPortWidth()));
}
break;
case Constants.Name.LEFT:{
holder = PropertyValuesHolder.ofFloat(Constants.Name.LEFT, domObject.getPositionLeft(),
WXViewUtils.getRealPxByWidth(WXUtils.getFloatByViewport(value, domObject.getViewPortWidth()), domObject.getViewPortWidth()));
}
break;
case Constants.Name.RIGHT:{
holder = PropertyValuesHolder.ofFloat(Constants.Name.RIGHT, domObject.getPositionRight(),
WXViewUtils.getRealPxByWidth(WXUtils.getFloatByViewport(value, domObject.getViewPortWidth()), domObject.getViewPortWidth()));
}
break;
case Constants.Name.BOTTOM:{
holder = PropertyValuesHolder.ofFloat(Constants.Name.BOTTOM, domObject.getPositionBottom(),
WXViewUtils.getRealPxByWidth(WXUtils.getFloatByViewport(value, domObject.getViewPortWidth()), domObject.getViewPortWidth()));
}
break;
case Constants.Name.TOP:{
holder = PropertyValuesHolder.ofFloat(Constants.Name.TOP, domObject.getPositionTop(),
WXViewUtils.getRealPxByWidth(WXUtils.getFloatByViewport(value, domObject.getViewPortWidth()), domObject.getViewPortWidth()));
}
break;
case Constants.Name.PADDING_TOP:{
holder = PropertyValuesHolder.ofFloat(Constants.Name.PADDING_TOP, domObject.getPadding().get(Spacing.TOP),
WXViewUtils.getRealPxByWidth(WXUtils.getFloatByViewport(value, domObject.getViewPortWidth()), domObject.getViewPortWidth()));
}
break;
case Constants.Name.PADDING_BOTTOM:{
holder = PropertyValuesHolder.ofFloat(Constants.Name.PADDING_BOTTOM, domObject.getPadding().get(Spacing.BOTTOM),
WXViewUtils.getRealPxByWidth(WXUtils.getFloatByViewport(value, domObject.getViewPortWidth()), domObject.getViewPortWidth()));
}
break;
case Constants.Name.PADDING_LEFT:{
holder = PropertyValuesHolder.ofFloat(Constants.Name.TOP, domObject.getPadding().get(Spacing.LEFT),
WXViewUtils.getRealPxByWidth(WXUtils.getFloatByViewport(value, domObject.getViewPortWidth()), domObject.getViewPortWidth()));
}
break;
case Constants.Name.PADDING_RIGHT:{
holder = PropertyValuesHolder.ofFloat(Constants.Name.TOP, domObject.getPadding().get(Spacing.RIGHT),
WXViewUtils.getRealPxByWidth(WXUtils.getFloatByViewport(value, domObject.getViewPortWidth()), domObject.getViewPortWidth()));
}
break;
default:
break;
}
Expand Down Expand Up @@ -466,6 +514,38 @@ public void onAnimationUpdate(ValueAnimator animation) {
domObject.setMargin(Spacing.BOTTOM, (Float) animation.getAnimatedValue(property));
}
break;
case Constants.Name.LEFT:{
domObject.setPositionLeft((Float) animation.getAnimatedValue(property));
}
break;
case Constants.Name.RIGHT:{
domObject.setPositionRight((Float) animation.getAnimatedValue(property));
}
break;
case Constants.Name.BOTTOM:{
domObject.setPositionBottom((Float) animation.getAnimatedValue(property));
}
break;
case Constants.Name.TOP:{
domObject.setPositionTop((Float) animation.getAnimatedValue(property));
}
break;
case Constants.Name.PADDING_TOP:{
domObject.setPadding(Spacing.TOP, (Float) animation.getAnimatedValue(property));
}
break;
case Constants.Name.PADDING_BOTTOM:{
domObject.setPadding(Spacing.BOTTOM, (Float) animation.getAnimatedValue(property));
}
break;
case Constants.Name.PADDING_LEFT:{
domObject.setPadding(Spacing.LEFT, (Float) animation.getAnimatedValue(property));
}
break;
case Constants.Name.PADDING_RIGHT:{
domObject.setPadding(Spacing.RIGHT, (Float) animation.getAnimatedValue(property));
}
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ private boolean shouldReport(int offsetX, int offsetY) {



private int calcContentOffset(RecyclerView recyclerView) {
public int calcContentOffset(RecyclerView recyclerView) {
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
int firstVisibleItemPosition = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ private int calcContentSize() {
return totalHeight;
}

private int calcContentOffset(RecyclerView recyclerView) {
public int calcContentOffset(RecyclerView recyclerView) {
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
int firstVisibleItemPosition = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,17 @@ public void onNestedPreScroll(View target, int dx, int dy, int[] consumed) {
}

if (moveSpinner(-spinnerDy)) {
consumed[1] += spinnerDy;
if (!canChildScrollUp() && mPullRefreshEnable
&& mTargetView.getTranslationY() > 0
&& dy > 0) {
consumed[1] += dy;
}else if (!canChildScrollDown() && mPullLoadEnable
&& mTargetView.getTranslationY() < 0
&& dy < 0){
consumed[1] += dy;
}else{
consumed[1] += spinnerDy;
}
}
}

Expand Down
5 changes: 2 additions & 3 deletions html5/runtime/vdom/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
} from './operation'
import { uniqueId } from '../utils'
import { getWeexElement, setElement } from './WeexElement'
import { filterDirective } from './directive'

const DEFAULT_TAG_NAME = 'div'
const BUBBLE_EVENTS = [
Expand Down Expand Up @@ -289,7 +288,7 @@ export default class Element extends Node {
const taskCenter = getTaskCenter(this.docId)
if (!silent && taskCenter) {
const result = {}
result[key] = filterDirective(value)
result[key] = value
taskCenter.send(
'dom',
{ action: 'updateAttrs' },
Expand Down Expand Up @@ -471,7 +470,7 @@ export default class Element extends Node {
const result = {
ref: this.ref.toString(),
type: this.type,
attr: filterDirective(this.attr),
attr: this.attr,
style: this.toStyle()
}
const event = []
Expand Down
69 changes: 0 additions & 69 deletions html5/runtime/vdom/directive.js

This file was deleted.

0 comments on commit 4b555f4

Please sign in to comment.