முக்கிய உள்ளடக்கத்திற்குச் செல்லவும்

scrollIntoView

டெஸ்க்டாப்/மொபைல் வெப் மற்றும் மொபைல் நேட்டிவ் ஆப்ஸ்க்கான எலிமெண்டை திரையில் தெரியும் வகையில் ஸ்க்ரோல் செய்தல்.

தகவல்

மொபைல் நேட்டிவ் ஆப்ஸில் ஸ்க்ரோலிங் மொபைல் swipe கமாண்டை அடிப்படையாகக் கொண்டது.

பயன்பாடு
$(selector).scrollIntoView({ behavior, block, inline, direction, maxScrolls, duration, scrollableElement, percent })
அளவுருக்கள்
பெயர்வகைவிவரங்கள்
options
optional
object, booleanElement.scrollIntoView()க்கான விருப்பங்கள். டெஸ்க்டாப்/மொபைல் வெப்பிற்கான இயல்புநிலை:
{ block: 'start', inline: 'nearest' }
மொபைல் நேட்டிவ் ஆப்பிற்கான இயல்புநிலை
{ maxScrolls: 10, scrollDirection: 'down' }
டெஸ்க்டாப்/மொபைல் வெப் மட்டும்
options.behavior
optional
stringMDN குறிப்பு ஐப் பார்க்கவும்.
வெப்-மட்டுமே (டெஸ்க்டாப்/மொபைல்)
options.block
optional
stringMDN குறிப்பு ஐப் பார்க்கவும்.
வெப்-மட்டுமே (டெஸ்க்டாப்/மொபைல்)
options.inline
optional
stringMDN குறிப்பு ஐப் பார்க்கவும்.
வெப்-மட்டுமே (டெஸ்க்டாப்/மொபைல்)
மொபைல் நேட்டிவ் ஆப் மட்டும்
options.direction
optional
stringdown, up, left அல்லது right என இருக்கலாம், இயல்புநிலை up.
மொபைல்-நேட்டிவ்-ஆப்-மட்டுமே
options.maxScrolls
optional
numberஎலிமெண்டைத் தேடுவதை நிறுத்தும் வரை அதிகபட்ச ஸ்க்ரோல்களின் எண்ணிக்கை, இயல்புநிலை 10.
மொபைல்-நேட்டிவ்-ஆப்-மட்டுமே
options.duration
optional
numberஸ்வைப்பிற்கான கால அளவு மில்லிவினாடிகளில். இயல்புநிலை 1500 மில்லிவினாடிகள். மதிப்பு குறைவாக இருந்தால், ஸ்வைப் வேகமாக இருக்கும்.
மொபைல்-நேட்டிவ்-ஆப்-மட்டுமே
options.scrollableElement
optional
Elementஉள்ளே ஸ்க்ரோல் செய்ய பயன்படுத்தப்படும் எலிமெண்ட். எந்த எலிமெண்டும் வழங்கப்படாவிட்டால், iOS க்கு -ios predicate string:type == "XCUIElementTypeApplication" மற்றும் Android க்கு //android.widget.ScrollView' என்ற செலக்டரைப் பயன்படுத்தும். இயல்புநிலை செலக்டருக்கு பல எலிமெண்ட்கள் பொருந்தினால், இயல்பாக முதல் பொருந்தும் எலிமெண்டைத் தேர்ந்தெடுக்கும்.
மொபைல்-நேட்டிவ்-ஆப்-மட்டுமே
options.percent
optional
numberஸ்வைப் செய்ய (இயல்புநிலை) ஸ்க்ரோலைபல் எலிமெண்டின் சதவீதம். இது 0 முதல் 1 வரை உள்ள மதிப்பு. இயல்புநிலை 0.95.
ஒருபோதும் திரையின் மேலே|கீழே|இடதுபுறம்|வலதுபுறத்திலிருந்து சரியாக ஸ்வைப் செய்யாதீர்கள், அறிவிப்புப் பட்டையை அல்லது பிற OS/ஆப் அம்சங்களை தூண்டக்கூடும், இது எதிர்பாராத முடிவுகளுக்கு வழிவகுக்கும்.
மொபைல்-நேட்டிவ்-ஆப்-மட்டுமே
எடுத்துக்காட்டுகள்
desktop.mobile.web.scrollIntoView.js
it('should demonstrate the desktop/mobile web scrollIntoView command', async () => {
const elem = await $('#myElement');
// scroll to specific element
await elem.scrollIntoView();
// center element within the viewport
await elem.scrollIntoView({ block: 'center', inline: 'center' });
});

mobile.native.app.scrollIntoView.js
it('should demonstrate the mobile native app scrollIntoView command', async () => {
const elem = await $('#myElement');
// scroll to a specific element in the default scrollable element for Android or iOS for a maximum of 10 scrolls
await elem.scrollIntoView();
// Scroll to the left in the scrollable element called '#scrollable' for a maximum of 5 scrolls
await elem.scrollIntoView({
direction: 'left',
maxScrolls: 5,
scrollableElement: $('#scrollable')
});
});

Welcome! How can I help?

WebdriverIO AI Copilot