Это то, что я использовал для этого (фрагмент, который у меня был некоторое время):
public function scanLatestFile($directory) {
// ignore any files that you don't want scanned
$ignoredFiles = array('.index.php', '.htaccess');
// Create new array to store the list of files
$filesToSearch = array();
// Scan the directory passed in
foreach (scandir($directory) as $file) {
if (in_array($file, $ignoredFiles)) continue;
// Add the filemtime so you can sort it
$filesToSearch[$file] = filemtime($dir . '/' . $file);
}
// Sort by latest file
arsort($filesToSearch);
$filesToSearch = array_keys($filesToSearch);
// Return latest file if it exists
return ($filesToSearch) ? $filesToSearch : false;
}
Это вернет последний файл в каталоге, также файлы игнорирования хорошо исключить все, что вы не хотите.
If it's not working why don't you try using jQuery's scrollTop method?
$("#id").scrollTop($("#id").scrollTop() + 100);
If you're looking to scroll smoothly you could use basic javascript setTimeout/setInterval function to make it scroll in increments of 1px over a set length of time.
Looks like you've got the syntax slightly wrong... I'm assuming based on your code that you're trying to scroll down 100px in 800ms, if so then this works (using scrollTo 1.4.1):
$.scrollTo('+=100px', 800, { axis:'y' });
jQuery теперь поддерживает scrollTop в качестве переменной анимации.
$("#id").animate({"scrollTop": $("#id").scrollTop() + 100});
Для плавной прокрутки больше не нужно использовать setTimeout / setInterval.