#StackBounty: #angular #css3 #scroll #sass Angular 6 – CSS – STICKY Header

Bounty: 50

I have 3 elements : 1 toolbar, 1 map , an other toolbar.
the elements are one below the other

I want that the second toolbar stay under the map element (at 400px of the top) but when i scroll down, my second toolbar will stop at 50px of the top and will fix under the first.

Thanks for your help

//Component.html

<mat-toolbar color="primary" [ngStyle]="{'height':'50px'}"  class="fixed-header" >
</mat-toolbar>

<mat-toolbar color="warn" class="mat-elevation-z5"> </mat-toolbar>

//Component.css

.fixed-header {
position: fixed;
z-index:999;
}

#frugalmap {
height: 300px;
width: 100%;
margin-top:50px;
}

.mat-elevation-z5 {
position: relative;
z-index: 2;
}


Get this bounty!!!

#StackBounty: #android #scroll #android-recyclerview #interpolation Why doesn't smooth scroll of RecyclerView work well with some I…

Bounty: 200

Background

In an effort to make a nice&short overview of the items on a horizontal RecyclerView, we want to have a bounce-like animation , that starts from some position, and goes to the beginning of the RecyclerView (say, from item 3 to item 0) .

The problem

For some reason, all Interpolator classes I try (illustration available here) don’t seem to allow items to go outside of the RecyclerView or bounce on it.

More specifically, I’ve tried OvershootInterpolator , BounceInterpolator and some other similar ones. I even tried AnticipateOvershootInterpolator. In most cases, it does a simple scrolling, without the special effect. on AnticipateOvershootInterpolator , it doesn’t even scroll…

What I’ve tried

Here’s the code of the POC I’ve made, to show the issue:

MainActivity.kt

class MainActivity : AppCompatActivity() {
    val handler = Handler()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val itemSize = resources.getDimensionPixelSize(R.dimen.list_item_size)
        val itemsCount = 6
        recyclerView.adapter = object : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
            override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
                val imageView = ImageView(this@MainActivity)
                imageView.setImageResource(android.R.drawable.sym_def_app_icon)
                imageView.layoutParams = RecyclerView.LayoutParams(itemSize, itemSize)
                return object : RecyclerView.ViewHolder(imageView) {}
            }

            override fun getItemCount(): Int = itemsCount

            override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
            }
        }
        val itemToGoTo = Math.min(3, itemsCount - 1)
        val scrollValue = itemSize * itemToGoTo
        recyclerView.post {
            recyclerView.scrollBy(scrollValue, 0)
            handler.postDelayed({
                recyclerView.smoothScrollBy(-scrollValue, 0, BounceInterpolator())
            }, 500L)
        }
    }
}

activity_main.xml

<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/recyclerView" xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
    android:layout_height="@dimen/list_item_size" android:orientation="horizontal"
    app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>

gradle file

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
    implementation 'androidx.core:core-ktx:1.0.0-rc02'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
    implementation 'androidx.recyclerview:recyclerview:1.0.0-rc02'
}

And here’s an animation of how it looks for BounceInterpolator , which as you can see doesn’t bounce at all :

enter image description here

Sample POC project available here

The question

Why doesn’t it work as expected, and how can I fix it?

Could RecyclerView work well with Interpolator for scrolling ?


EDIT: seems it’s a bug, as I can’t use any “interesting” interpolator for RecyclerView scrolling, so I’ve reported about it here .


Get this bounty!!!

#StackBounty: #javascript #scroll #mousewheel #gestures #trackpad Prevent page navigation on horizontal scroll

Bounty: 50

I am using a mac trackpad.How to prevent the page going back and next to visited pages on horizontal scroll ?.

I tried to prevent the wheel events but it doesn’t works most of the time.

container.addEventListener('wheel', function(ev) {
    ev.preventDefault();
    ev.stopPropagation();
    return false;
}, {passive: false, capture: true});

even I tried blocking with mousewheel event which also leads to page navigation.


Get this bounty!!!

#StackBounty: #android #animation #scroll #android-tablayout #android-coordinatorlayout CoordinatorLayout + TabView + AnimateView(From …

Bounty: 50

Yesterday I am playing with CoordinatorLayout with TabView

1) What is my target ?

  • CoordinatorLayout with TabView
  • When I scroll up at that time One View As show in .GIF move down.
  • and Stick on the Top of the TabView (inside AppBar).

enter image description here

2) Where I reached ?

  • CoordinatorLayout with TabView with pretty scrolling.
  • TabView with Appbar Stop Scrolling At Top after Then Scroll RecyclerView.

enter image description here

3) Where I stuck ?

  • When I scroll Up One View Scroll Down but TabView Stick At Top not like 1st gif.

4) Code snippet

  • Xml file
    <android.support.design.widget.AppBarLayout
        android:id="@+id/main.appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
        <!--- ADD TAB_LAYOUT HERE -->
    
    
        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/main.collapsing"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll">
    
            <ImageView
                android:id="@+id/main.backdrop"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/abc"
                app:layout_collapseMode="none" />
    
    
            <!-- ADD ANY THING THAT GETS SCROLLED ALL THE WAY UP WITH TOOLBAR -->
        </android.support.design.widget.CollapsingToolbarLayout>
    
    
        <!-- our tablayout to display tabs  -->
        <android.support.design.widget.TabLayout
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/colorPrimary"
            android:minHeight="?attr/actionBarSize"
    
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
    
    
    </android.support.design.widget.AppBarLayout>
    
    
    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
    

  • Java file (move upper view down code)
    AppBarLayout ab = (AppBarLayout) findViewById(R.id.main_appbar);ab.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    
            int ScrollStart = (ab.getHeight() - tabLayout.getHeight() - llTop.getHeight() - llTop.getHeight());
            int scrollStop = (ab.getHeight() - tabLayout.getHeight() - llTop.getHeight());
            if ((-verticalOffset) > ScrollStart && (-verticalOffset) < scrollStop) {
                llTop.setVisibility(View.VISIBLE);
                llTop.setTranslationY(((-verticalOffset) - ScrollStart) - llTop.getHeight());
                Log.e("point", "" + ((-verticalOffset) - ScrollStart));
    
            } else if ((-verticalOffset) >= scrollStop) {
                llTop.setVisibility(View.VISIBLE);
            } else {
                llTop.setVisibility(View.INVISIBLE);
            }
    
    
        }
    });
    


Get this bounty!!!